Animate Bones; make Bones default player

This commit is contained in:
RochesterX
2025-01-15 16:55:07 -05:00
parent 4c2830769b
commit 1315bdb7dc
9 changed files with 1941 additions and 854 deletions

View File

@@ -3,6 +3,11 @@ using UnityEngine;
[RequireComponent(typeof(Animator))]
public class AnimationPlayer : MonoBehaviour
{
public enum AnimationState { Idle, Run, Jump };
public AnimationState state;
public bool backwards;
public AnimationClip clip;
private Animator animator;
@@ -12,4 +17,15 @@ public class AnimationPlayer : MonoBehaviour
animator = GetComponent<Animator>();
animator.Play(clip.name);
}
private void LateUpdate()
{
animator.SetInteger("state", (int)state);
transform.localScale = new Vector3(Mathf.Sign(backwards ? -1 : 1) * Mathf.Abs(transform.localScale.x), transform.localScale.y, transform.localScale.z);
}
public void SetState(AnimationState state)
{
this.state = state;
}
}