I am making a 2.5D game where the player can only move up, down, right or left; no X-Axis
I have the controls set-up like this:
using UnityEngine;
public class Movement : MonoBehaviour
{
public float speed = 8;
private Vector3 scale = new Vector3(5, 5, 5);
private Rigidbody rb;
void Start()
{
rb = GetComponent<Rigidbody>();
}
void Update()
{
transform.localScale = scale;
if (Input.GetKey(KeyCode.S))
{
transform.localScale = new Vector3(5, 2, 5);
}
}
void FixedUpdate()
{
float mH = -Input.GetAxis("Horizontal");
rb.velocity = new Vector3(0, rb.velocity.y, mH * speed);
}
}
the problem is that the character should turn when it is heading in the opposite direction, i could just flip it with the rotation or set the Z scale negative, but that would make it turn istantly, i want to have it turn in the span of a few frames so it doesn't seem unnatural. How can i proceed to implement something like that? Is it even possible in unity?

