Rotating on other axis
Ok guys Thanks for giving time for my problem I'm actually trying to make a basic plane controler, and making the rotation of this plane with virtual Joystick.
If Joystick moved up/down, the plane rotate up/down based on plane's right axis and if Joystick moved left/right, the plane rotate right/left based on plane's up axis
But I need to rotate the plane on camera's axis wich are the right axis and not plane's axis. How can I do that ? Already tried (for up/down) :
transform.Rotate(Vector3.right, ValueToRotate);
transform.Rotate(cam.transform.right, ValueToRotate);
transform.Rotate(cam.Vector3.right, ValueToRotate);
transform.Rotate(cam.transform.TransformDirection(transform.right),ValueToRotate);
transform.Rotate(cam.transform.TransformDirection(cam.transform.right),ValueToRotate);
Sometime it is based on world axis with vector3, sometime I got weird rotation(0° work,45° rotate on forward Axis, 90° up down inverted, 135° rotate on forward axis, 180° work) wut ? XD It could be great to find how to do it. Thanks for your anwser
Answer by Bunny83 · Sep 26, 2020 at 01:22 AM
transform.Rotate by default rotates around a local space axis. It has an optional parameter to specify the space.
transform.Rotate(cam.transform.right, ValueToRotate, Space.World);
oh ... that was this simple XD Thanks for your respond I Thought Space.World was for taking vector based on world (like a Vector3.up), but it s not that. Thanks a lot it work quite well now ^^
Your answer
Follow this Question
Related Questions
ROTATION STOPS when i move the char on the air! 0 Answers
have one object rotate another object on the y axis 0 Answers
how to rotate a mesh with GetMouseButton with specific rotation value 2 Answers
How to object rotate on a single axis towards another object? C# 2 Answers
How to rotate an object according to the camera's view? 1 Answer