- Home /
Rotation of player based on camera direction and joystick direction in 3D world
Basically, i have a joystick, a camera, and a player. The camera is always facing the same direction and simply follows the player around, and what i want is to make the player rotate left when i drag my joystick left. I'm already moving the player's position based on the camera direction, for example when i drag joystick left, the player starts moving left not in "World's Left", but in "Camera's Left", what is missing is to also rotate the player but taking into account the joystick direction. i have a joystick.Direction which i can use but dont know exactly how (and also Horizontal and Vertical values). Thanks in advance.
Answer by unity_ek98vnTRplGj8Q · Feb 20, 2020 at 05:48 PM
Do you just want to rotate the player to face the direction hes moving? If so you can use Quaternion.LookRotation with your movement vector;
Vector3 movementDirection; //You should already have this
transform.rotation = Quaternion.LookRotation(movementDirection, Vector3.up);
Your answer
Follow this Question
Related Questions
Player jitters when moving. 1 Answer
Model Viewer Camera Rotation 0 Answers
advanced problem for me regarding transfering rotation from the gizmo to the object 0 Answers
Unity cam problem 1 Answer
move the object where camera look 0 Answers