using System.Collections; using System.Collections.Generic; using Platformer.Core; using Platformer.Model; using UnityEngine; namespace Platformer.Mechanics { /// /// AnimationController integrates physics and animation. It is generally used for simple enemy animation. /// [RequireComponent(typeof(SpriteRenderer), typeof(Animator))] public class AnimationController : KinematicObject { /// /// Max horizontal speed. /// public float maxSpeed = 7; /// /// Max jump velocity /// public float jumpTakeOffSpeed = 7; /// /// Used to indicated desired direction of travel. /// public Vector2 move; /// /// Set to true to initiate a jump. /// public bool jump; /// /// Set to true to set the current jump velocity to zero. /// public bool stopJump; SpriteRenderer spriteRenderer; Animator animator; PlatformerModel model = Simulation.GetModel(); protected virtual void Awake() { spriteRenderer = GetComponent(); animator = GetComponent(); } protected override void ComputeVelocity() { if (jump && IsGrounded) { velocity.y = jumpTakeOffSpeed * model.jumpModifier; jump = false; } else if (stopJump) { stopJump = false; if (velocity.y > 0) { velocity.y = velocity.y * model.jumpDeceleration; } } // PD 명시 2026-05-08 — PlayerController와 동일 영역 정합: 좌측 향한 sprite 기준 우측 이동 시 flipX=true if (move.x > 0.01f) spriteRenderer.flipX = true; else if (move.x < -0.01f) spriteRenderer.flipX = false; animator.SetBool("grounded", IsGrounded); animator.SetFloat("velocityX", Mathf.Abs(velocity.x) / maxSpeed); targetVelocity = move * maxSpeed; } } }