i am stuck making a gun.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Zubayer

Im new to godot and am stuck making a gun for my character. This game is a platforming game.

You’ll have to provide more information. Do you mean the graphics of the gun? The physical placement/attachment to the character? Or are you stuck trying to make bullets that are fired by the gun?

kidscancode | 2018-07-03 20:55

I am stuck trying to make the bullets that are fired by the gun.

Zubayer | 2018-07-03 21:03

:bust_in_silhouette: Reply From: kidscancode

It’s hard to answer such a general question. The KinematicBody2D tutorial has an example of firing bullets from a gun. You can also look at some of the official demos.

If you have a specific question about something you’re trying that’s not working, you’ll be a lot more likely to get an answer here.

:bust_in_silhouette: Reply From: Tova

you could make a bullet in a separate scene, and then when you fire a gun you make an instance of the bullet and set its position, something like this

var bullet_scene = load("res://bullet.tscn")
if shoot:
	var bullet = bullet_scene.instance()
	bullet.position = position 
	add_child(bullet)

i would use something like this on a script for the gun, and on the bullet scene i would add a script which moves the bullet

Two problems with this:

  1. You also need to set the direction of the bullet to the player’s facing.
  2. If you make the bullet a child of the player, it will follow the player as he/she moves.

kidscancode | 2018-07-04 16:57