Rotate gameobject relative to it's own rotation
Hi, so I'm having alot of trouble trying to figure this out, so if anyone could spare a hand I'd really appreciate it. I have an object that can rotate to look forward to the direction the camera is facing, I managed to achieve that but now I want the object to rotate left or right depending on it's own Y rotation, since it's constantly changing it's Y rot, but to stick to the right or left angle, not to keep rotating indefinitely. So for example if I press A, I want it to rotate ONLY the desired degrees to look at the left instead of keep going. I am looking ONLY to rotate the object, not to move it.
I hope this basic drawing can help understand a little bit more what I'm looking for. Any help will be appreciated, I'm having such a hard time with this. :c thanks in advantage.
Answer by streeetwalker · Mar 24, 2020 at 05:43 AM
It depends on how you're trying to implement this behavior and what you want to have happen.
A.) are you controlling the camera and moving/rotating the object,
or
B.) are you controlling the object and moving/rotating the camera?
And
1.) Do you always want the camera to maintain the same relative orientation (distance and rotation ) with the object,
or
2.) do you want to be able to change distance and rotation of the camera relative to the player?
Probably the simplest way to arrange this is to parent the camera to the object, and then control the object. You'll have no problem rotating the object and the camera will always be pointed in the proper direction.
beyond that, if your having problems with rotation not stopping then the animation algorithm is not correctly aligned with your intent.
Your answer
Follow this Question
Related Questions
How to make a turn like the Temple Run and NO THING ? 2 Answers
My Player rotates on the Z axis, but not the X axis. Why? 0 Answers
disable gameobject after rotation limit 1 Answer
Controller Rotation returns to Zero when there is no movement. 0 Answers
How can I add both animator and script rotation on Game object? 0 Answers