Question by
Entaurus · Oct 30, 2020 at 10:26 AM ·
animator controlleridle animations
Idle animation doesn't work correctly
I'm trying to make 2d top view game and i have 4 different idle animations for 4 states of my character.
If character was moving to right he gonna play idle animation that looking to the right side, if top - top side idle animation.
Character moves as i wanted, but always plays idle animation that i transitioned from blend tree. When i transitioning to another animations - they just don't playing.
using System.Collections; using System.Collections.Generic; using System.Threading; using UnityEngine;
public class PlayerMovement : MonoBehaviour {
public float moveSpeed = 5f;
public Rigidbody2D rb;
public Animator animator;
Vector2 movement;
// Update is called once per frame
void Update()
{
movement.x = Input.GetAxisRaw("Horizontal");
movement.y = Input.GetAxisRaw("Vertical");
animator.SetFloat("Horizontal", movement.x);
animator.SetFloat("Vertical", movement.y);
animator.SetFloat("Speed", movement.sqrMagnitude);
}
void FixedUpdate()
{
rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);
}
}
Comment