I am trying to add rotation to my player and he keeps during wide and I do not know how to fix. Does anyone know.
My Script:
using UnityEngine;
public class CharacterController : MonoBehaviour
{
public float MovementSpeed = 1;
private Rigidbody2D _rigidbody;
private void Start()
{
_rigidbody = GetComponent<Rigidbody2D>();
}
private void Update()
{
var movement = Input.GetAxis("Horizontal");
transform.position += new Vector3(movement, 0, 0) * Time.deltaTime * MovementSpeed;
transform.Translate(Input.GetAxis("Horizontal")* 15f * Time.deltaTime, 0f, 0f);
Vector3 characterScale = transform.localScale;
if (Input.GetAxis("Horizontal") < 0)
{
characterScale.x = -10;
}
if (Input.GetAxis("Horizontal") > 0)
{
characterScale.x = 10;
}
transform.localScale = characterScale;
}
}