|
Post by britannis on Apr 16, 2016 5:32:24 GMT
I've heard if an object has a rigidbody and I want to move it in a way that causes the physics system to interact with colliders, then I should move the rigidbody instead of the transform. However, I'm having an issue with rotation. This is my movement line:
// We use fixed update since we are moving a rigidbody. void FixedUpdate() { myRigidbody.MovePosition(myRigidbody.position + velocity * Time.fixedDeltaTime); } For rotation, I'm actually rotating the transform based on camera rotation code I found on the forums. The idea is the camera should rotate based on where the player's mouse is. Here is the line that rotates the transform after the camera calculations are done:
transform.localRotation = yRotation * Quaternion.Euler(transform.localRotation.eulerAngles);
Any idea how to make my rigidbody move forward while accounting for rotation? Right now if I press W, the character moves forward as if it has not rotated at all.
|
|