Пожалуйста помогите решить проблему с командой Flip. При передвижении персонажа она не работает.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Movement : MonoBehaviour
{
public float speed;
private Rigidbody2D rb;
private Vector2 moveVelositi;
private bool facingRight = true;
private float moveInput;
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
void Update()
{
Vector2 moveInput = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
moveVelositi = moveInput.normalized * speed;
}
void FixedUpdate()
{
rb.MovePosition(rb.position + moveVelositi * Time.fixedDeltaTime);
if (facingRight == false && moveInput > 0)
{
Flip();
}
else if (facingRight == true && moveInput < 0)
{
Flip();
}
}
void Flip()
{
facingRight = !facingRight;
Vector3 Scaler = transform.localScale;
Scaler.x *= -1;
transform.localScale = Scaler;
}
}