Question by
tarung1201 · Dec 02, 2018 at 12:42 PM ·
rotation3dquaternionjoystick
Rotation on moving using virtual joystick is not working as expected in 3D game.
var rigidbody = GetComponent(); rigidbody.velocity = new Vector3(joystick.Horizontal 4f, rigidbody.velocity.y, joystick.Vertical 4f);
Vector3 moveVector = (Vector3.right * joystick.Horizontal + Vector3.forward * joystick.Vertical);
if (moveVector != Vector3.zero)
{
Quaternion newRotation = Quaternion.LookRotation(moveVector, Vector3.left);
rigidbody.MoveRotation(newRotation);
}
I'm using the above script to rotate my object. But it first rotates my object in different axis on pressing the joystick as shown in picture.
consolidateimage.jpg
(92.9 kB)
Comment
Your answer
Follow this Question
Related Questions
Draw a ray from a gamobject and keep direction of the ray relative to the gameobjects rotation. 1 Answer
How to Rotate Y axis of an Object toward virtual joystick direction 0 Answers
How to avoid single direction rotation with Quaternions? 0 Answers