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).