I’m confused as to why my character sprites rotate when moving. Does anyone know the cause?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerMovement : MonoBehaviour
{
[SerializeField] float runSpeed = .5f;
Vector2 moveInput;
Rigidbody2D myRigidbody;
void Start()
{
myRigidbody = GetComponent<Rigidbody2D>();
}
void Update()
{
Run();
}
void OnMove(InputValue value)
{
moveInput = value.Get<Vector2>();
Debug.Log(moveInput);
}
void Run()
{
Vector2 playerVelocity = new Vector2 (moveInput.x * runSpeed, myRigidbody.velocity.y);
myRigidbody.velocity = playerVelocity;
}
}