My LookRotation forces my character to snap back, and face starting direction after I stop moving?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NewBehaviourScript : MonoBehaviour {

public float speed = 6.0F;
public float jumpSpeed = 8.0F;
public float gravity = 20.0F;
private Vector3 moveDirection = Vector3.zero;

private CharacterController controller;

private void Awake()
{
	controller = GetComponent<CharacterController>();
}

void Update()
{
	if (controller.isGrounded)
	{
		moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));

		Quaternion rotation = Quaternion.LookRotation(moveDirection, Vector3.up);
		transform.rotation = rotation;

		moveDirection *= speed;
		if (Input.GetButton("Jump"))
		{
			moveDirection.y = jumpSpeed;
		}

		Debug.DrawLine(transform.position, moveDirection);

	}
	moveDirection.y -= gravity * Time.deltaTime;
	controller.Move(moveDirection * Time.deltaTime);
}

}

Well, your code is a bit confusing as I’m not sure whether you are trying to achieve movement (moving) or rotation (turning), so I will give you an example of both and let you modify as you see fit.

Assign the following script (name it MoveDirection.cs) to an object and play

using UnityEngine;

public class MoveDirection : MonoBehaviour
{
	public float turnRate;
	public float moveSpeed;

	public bool move;

	private void Update()
	{

		// Use spacebar to switch between moving and turning.
		if (Input.GetKeyDown(KeyCode.Space))
			move = !move;

		Vector2 _getAxis = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));

		if (move)
		{
			Debug.Log("moving");
			transform.Translate(
			  _getAxis.x * moveSpeed * Time.deltaTime,
			  0,
			  _getAxis.y * moveSpeed * Time.deltaTime,
			  Space.Self);
		}
		else
		{
			Debug.Log("turning");
			transform.Rotate(
				_getAxis.x * turnRate * Time.deltaTime,
				_getAxis.y * turnRate * Time.deltaTime,
				0,
				Space.Self);
		}
	}
}

Well, you’re rotating based on Input.GetAxis. If you stop moving, your input axis is 0, which will default you back to the same rotation each time. Check whether or not the appropriate input is provided, then if so, rotate accordingly (or otherwise, do nothing).

Hope that helps!