- Home /
Parent an objects position without its rotation
I have a bullet moving forward and rotating along the z axis. I have a camera that I am trying to move forward with the bullet from a distance AND rotate around it. Everything works great when I set the cameras transform parent to the bullets transform, except (as expected), when the bullet rotates, it's rotating the camera. The bullet is moving at a very high rate of speed, but in slow motion. How can I get the camera to rotate around the bullet on its (the cameras) y axis without it rotating WITH the bullet on its (the bullets) z-axis?
What I've tried :
RotateAround with the camera, not transform childs/parents between the cam and bullet. With this setup, it seems the bullet is moving so fast that the camera kind of pans out, the distance between them increases dramatically with every update.
Making the camera's transform parent the bullets transform. Works exactly the way I want EXCEPT the camera rotates with the bullet around the bullets z axis (the bullet is rotating as a bullet would from the barrel, but since the cameras transform is a child of it, the camera gets rotated incorrectly.
I can't seem to wrap my head around a solution other than creating an Empty game object, using it as a 'bullet', and then creating the actual bullet object and camera, both with their transform parents set to this "blank" bullet. This way when the bullet rotates, it won't affect the camera, but they'd be moving at the same speed, etc.
Is there an easier solution for this?
Answer by simonmc · Oct 13, 2011 at 02:19 AM
An empty gameobject with both the camera and bullet attached is definitely the easist solution. This is fairly trivial so I don't know why you are wanting to avoid doing this.