
Вот. Спрайт во время бега поворачивается. Анимации проигрываются, но когда персонаж останавливается, всегда поворачивается вниз... Что делать?
Скрипт
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player_Controller : MonoBehaviour
{
public float speed;
public Animator animator;
private Vector2 direction;
private Rigidbody2D rb;
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
void Update()
{
direction.x = Input.GetAxisRaw("Horizontal");
direction.y = Input.GetAxisRaw("Vertical");
animator.SetFloat("Horizontal", direction.x);
animator.SetFloat("Vertical", direction.y);
animator.SetFloat("Speed", direction.sqrMagnitude);
}
void FixedUpdate()
{
rb.MovePosition(rb.position + direction * speed * Time.fixedDeltaTime);
}
}