How do I get my projectile to shoot from the correct position?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By chillymegacd

Gun shooting bullet at incorrect position
So I’m trying to recreate how the Ship A from DoDonPachi works, with two guns circling the ship. However, it won’t fire from the gun, those bullets off to the right should be coming out of the square to the right of the ship. Here’s the code for the gun: extends Node2Dvar time = 1.0var speed = 10var distance_from_center = 15 -

:bust_in_silhouette: Reply From: zhyrin

You are setting the bullet’s local position to a global position.
gunbullet.global_position = sprite.global_position on line 15 should do it.

Bullet moving along with gun: Pasteboard - Uploaded Image
Hi, I just wanted to thank you for your response. I tried what you did and while it shoots from the gun now all of the bullets positions are the same as the gun on the x axis. I was wondering if there was a way to have them shoot more like my player object in the screenshot above. Notice how as I move, the gun bullets move along with me while the player ones don’t (Slowed down fire rate for clarity). Here’s the player script for reference: Player Script -

chillymegacd | 2023-02-10 19:49