- Home /
How to keep gameobject transform relative to parent
Hi.
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?
Thanks, Alex
Answer by hectorux · Nov 04, 2018 at 03:25 PM
Are you using a Vector3.forward? this is world absolute, try transform.forward, or in your case gun.forward(gun is a Transform)
Your answer
Follow this Question
Related Questions
Correct way to spawn and move objects 1 Answer
Change gameobjects position if it's already used by a different gameobject? 1 Answer
Client's list of game object prefabs not shown in the Server. How do I solve this? 0 Answers
Can You Convert a Transform into an Image? 2 Answers
my character is going through walls and other objects 2 Answers