Не работает скрипт на объекте в Unity
это сам код:
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour
{
public float maxspeed = 10f;
private bool flipRight = true;
void Update()
{
float move = Input.GetAxis("Horizontal");
GetComponent<Rigidbody>().velocity = new Vector2(move * maxspeed, GetComponent<Rigidbody2D>().velocity.y);
if (move > 0 && !flipRight)
{
Flip();
}
else if (move < 0 && flipRight)
{
Flip();
}
}
private void Flip()
{
flipRight = !flipRight;
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
}
}
