#How do I make bullets shoot out of my player
40 messages · Page 1 of 1 (latest)
Often people use Areas
okay
what do i do now
What are you struggling with? Actually spawning the bullets?
You’ll need a preload variable in your player scene. This is a reference to the bullet
var bullet_scene = preload(PATH TO BULLET SCENE)
then you can create a new function, maybe call it shoot_bullet()
In that function you have to instantiate the bullet scene and add it to the world.
get_parent().add_child(instance)
instance.global_position = global_position
instance.look_at(get_global_mouse_position) ```
This will spawn the bullet where the player is and make the bullet look at the mouse
it gave me this error
oh
What about shooting
Call the function you just wrote every time you want to spawn a bullet
No I mean like how does the bullet shoot
You have to make the bullet move the same way you made the player move
Right now you have no code in your bullet scene right?
You’d need some movement code for the bullet then
How
How experienced are you with godot?
The bullet doesn’t have to do more than go in a straight line
Global_position += global_transform.x * delta * 100 for example should work