my character rotation snaps back to starting rotation and says

public class PlayerController : MonoBehaviour {

Rigidbody rigidBody;
public float speed = 6f;

// Use this for initialization
void Start () {

	rigidBody = GetComponent <Rigidbody>();


// Update is called once per frame
void FixedUpdate () {

	float moveVertical = Input.GetAxisRaw ("Vertical") * speed * Time.deltaTime;
	float moveHorizontal = Input.GetAxisRaw ("Horizontal") * speed * Time.deltaTime;
	Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);

	rigidBody.MoveRotation (Quaternion.LookRotation (movement));

	rigidBody.MovePosition (rigidBody.position + (movement));



There are different solutions, but let’s solve your problem the simplest way: You are always looking into the direction of the input. When not pressing anything, it will still look into the direction of, which will by default pick the z-axis I believe. So only adjust rotation when the new direction is actually different from zero. Also, it is best to poll for input in Update to make sure you actually catch all input signals and then apply physics in FixedUpdate, which runs at a slower rate. Polling in FixedUpdate may lead to dropped input events, because they are simply missed sometimes. And for a next stop you would actually only want to rotate, if your input dictates a new rotation that is different from your previous one.

public class Test : MonoBehaviour
private float speed = 6f;

	private Rigidbody rigidBody;
	// delta means "how much difference in this frame"
	private Vector3 moveDelta; 

	private void Start()
		rigidBody = GetComponent<Rigidbody>();

	private void Update()
		float x = Input.GetAxisRaw("Horizontal");
		float z = Input.GetAxisRaw("Vertical");
		// map input axis to world axis here.
		moveDelta = new Vector3(x, 0.0f, z) * speed * Time.deltaTime; 

	private void FixedUpdate()
		rigidBody.MovePosition(rigidBody.position + moveDelta);

	/// <summary>
	/// Only rotates the rigidbody to the input direction, if input
	/// is not zero.
	/// </summary>
	private void RotateIfNewDirection(Vector3 input)
		//if(input ==

		// This is better because your input might not be perfectly zero, when not pressing an axis.
		if(input.magnitude < 0.01f)

		rigidBody.rotation = Quaternion.LookRotation(input);