0 votes

im trying to make a gun that shoots in a direction of the gun's rotation, how do i do that?

Godot version 3.2.3
in Engine by (16 points)

1 Answer

+1 vote

Get the guns rotation and apply it to the bullets rotation.
Something like

 bullet.rotation = gun.rotation

Another thing, the bullet should not be a child of the gun. It should be a child of the level itself so if you instanciate it at the gun scene make sure you declare it as so.

get_parent().add_child(bullet)
by (2,017 points)

yeah but, for example, if im aiming down, the gun have to shoot down, if im aiming up, the gun have to shoot up

Add a position2d node in your gun Scene at the end of the muzzle and when you create your bullets make their global position to be there.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.