UP-Viagg-io/Viagg-io/Assets/SetAnimationFrame.cs
2025-05-20 16:59:09 +02:00

23 lines
688 B
C#

using UnityEngine;
public class SetAnimationFrame : MonoBehaviour
{
public string animationStateName = "YourAnimationState"; // Exact state name
public float freezeTime = 0.99f; // Use 1.0f or 0.99f to stay at the last frame (safe against overshooting)
private Animator animator;
void Start()
{
animator = GetComponent<Animator>();
// Play the animation state at a specific normalized time (0=start, 1=end)
animator.Play(animationStateName, 0, freezeTime);
// Immediately update the animator once to apply that pose
animator.Update(0);
// Disable the Animator to freeze it
animator.enabled = false;
}
}