- Edited
As seen below, I want the bullet to spawn where the end of the gun is. How would I go about doing that?
As seen below, I want the bullet to spawn where the end of the gun is. How would I go about doing that?
I'd add a Position2D node to the end of the gun, as a child of the gun node, and then spawn the bullet and muzzle flash at its position. For the muzzle flash, you can probably just get away with already having the node(s) there, just make them visible/invisible when you need them. For the bullet, you just need to get the node's global position using something like bullet.global_position = get_node("gun/position2d").global_position
:smile:
Also, please do not add a topic-only tag like "(HELP NEEDED)" to your posts, as its against the recommendations of the forum. Generally every question and most topics are looking for help, so there is no reason to add a topic-only tag. Not to mention, anyone who was going to look at the topic will regardless of the topic tag. I removed the tag from the topic, but in the future, please avoid using it. Thanks!
That is the way I handle those types of positions too, is using an empty node. But you can calculate it from the objects position. If your animation is animated, and the gun visual changes. For 3d I can attach an empty to an object. Such as a gun. Which is mounted to a bone in the character. For 2d, I cant help you with it on animations because of how it's done. One big reason I use 3d rather than 2d. If you can animated the empty nodes positoin and match it with your sprite.