Hello experts!
In my game there is a player and its arm with a gun. This arm is independent from the player, so it can be rotating with the mouse. I would like that the bullets create at the front of the gun.
The trick is that the origin of this armed gun at its right end, not the left where the player look. I would like create the bullets away from this origin to the width of the sprite of the gun.
Here is my code:
if (Input.is_mouse_button_pressed(BUTTON_LEFT) and can_shoot==true):
var b=bullet.instance()
get_parent().add_child(b)
b.position=position #This should be supplemented with offset by the width of the sprite
b.rotation=(get_global_mouse_position()-self.position).angle()+45