#Trying to find some good approaches to handling projectiles
6 messages · Page 1 of 1 (latest)
you can add them directly to your world scene
so it can move independently from your player
I was thinking that, but then I was wondering what would be the best way to attach it, as I don't know how many nodes deep the shooter might be, and going up the tree with get node is a bad idea anyway with how brittle it leaves things.
When you add the shooter to the scene_tree, there is always a node on top of it, like the viewport
so should be safe to get_node on top of it
you could also emit signal when you shoot, but you can no longer test in isolation without the listener that adds the bullets to the world
Not everyone agree with this approach, but you can use a dedicated node as projectile parent
I would just add it to the scene tree with get_tree().root.add_child(...).
Do you need to "retrieve" these bullets again? Wondering where the position of the bullets in the scene tree affect your use case (if it does).