- Home /
Rotate object relative to camera's view
Ok so I have a game where my fps character can pick up and move objects, I want to make it so they can also rotate the object, but I can't seem to figure out how to make the object rotate relative to the camera's view. So when the player rotates the object if they rotate the object left then up it throws off all of the controls. Any suggestions?
Answer by adriandevera · Jun 21, 2015 at 11:29 AM
With the rotation you can specify the rotation locally or in relation to the world. If you check here:
http://docs.unity3d.com/ScriptReference/Transform.Rotate.html
you will find a sample utilizing Space.World. If that doesnt work you can try Space.Self as well and see how it is affected.
Thanks, Using Rotate and I set the objects rotation relative to the cameras.
Were you able to figure out how to rotate an object relative the the camera? Can you share your code?
Answer by HammerCar · Jun 20, 2015 at 07:01 PM
I think I would parent the object to the player or the camera (depending on what you want) when the player picks it up, and unparent it after the player relases it.
You can do this with transform.parent = (objects transform here);
Your answer
Follow this Question
Related Questions
Camera follows target rotation 3 Answers
Rotate object in 90 degrees relative to camera. 1 Answer
Instantiate gun & arms rig relative to rotation & position of first person controller camera 0 Answers
Rotate camera only in 2 directions based on player touch 1 Answer
How to pan-rotate camera transform parallel to its view plane? 1 Answer