- Home /
Help with Quaternions and Vector3s
Quaternion newRotation = Quaternion.LookRotation(playerToMouse); playerRigidbody.MovePosition (newRotation); With this code, I'm getting the error "Argument 1: cannot convert from 'UnityEngine.Quaternion' to 'UnityEngine.Vector3' ". I am following the Survival Shooter Tutorial, but am getting an error from the code they wrote. Maybe an issue with the newer version of Unity?
I'm following the official Unity 3D tutorial on their website, and I double checked to make sure I typed everything correctly. They are using an older version of Unity, so I'm not sure if that has anything to do with it... Any idea of how I could change the code to make it work correctly?
Answer by saschandroid · Nov 05, 2015 at 07:08 AM
From what I see in the tutorial code:
// Create a quaternion (rotation) based on looking down the vector from the player to the mouse.
Quaternion newRotation = Quaternion.LookRotation (playerToMouse);
// Set the player's rotation to this new rotation.
playerRigidbody.MoveRotation (newRotation);
So it's NOT playerRigidbody.MovePosition but playerRigidbody.MoveRotation
Answer by fafase · Nov 04, 2015 at 08:32 PM
Rigidbody.MovePosition(Vector3);
this method expects a Vector3 but your newRotation is a rotation. Either you should stop the tutorial right now as it is a pile of junk or you did not follow exactly (maybe a bit of both).
The first line gets a rotation while the second line performs a movement. You must have something missing in between. Event converting your rotation to a vector3 would not make sense as you get a rotation and MovePosition should get a position to move to.