How to keep gameobject transform relative to parent


I have a gun gameobject with spawn points for the projectiles as child objects. I have set the bullets to spawn and move in the Z direction (not as children) based on the position of the child gameobjects. However, when the player changes direction, “forwards” is on a different axis. How would I keep the Z axis pointing wherever I point the gun?


Are you using a Vector3.forward? this is world absolute, try transform.forward, or in your case gun.forward(gun is a Transform)