- Home /
freeze y-axis on (camera-) attached object
Hi,
I have a trolley/cart attached to my camera. When I walk the trolley follows (which is good^^). But when I pan the view the trolley gets panned with the cam. This is good for the x-axis (as I need it like that). But when I look up and down I want the trolley not to follow that movement. It should rather stay at the horizontal level...
Can somebody help? Thanks and Regards
JF
Answer by Ben Holmes · Apr 06, 2011 at 06:06 PM
you probably don't want your cart to be attached to the camera object. The simplest way would be to write a script which gets the rotation of the camera and rotates the cart appropriately. That way you can simply ignore the rotation around the x-axis (i.e. looking up or down).
btw shouldnt the trolley be attached to somewhere? Otherwise its not following as you move... ?!
the script you write should update the cart's position and rotation so that, in effect, the cart is attached to the camera but not in the scene hierarchy. The problem with parenting the cart to the camera is that it will inherit all the changes from the camera's transform and you don't all of them (you want to ignore the up and down rotation). using a script you can copy values from the camera's transform into the cart's transform manually. This allows you to simply ignore the up-down rotation from the camera.
Your answer
Follow this Question
Related Questions
fixing rotation on a specific axis 1 Answer
Rotate object on the Y axis 90 degrees every 5 minutes? 1 Answer
2d axis is not shown 1 Answer
Rotation Object Follow Help 2 Answers
Problems with the axes of the object 1 Answer