Files
aibis-dream/Assets/Scripts/SceneManagement/Actor.cs
T

56 lines
1.1 KiB
C#

using UnityEngine;
public class Actor : MonoBehaviour
{
private Animator animator;
private void Awake()
{
// 自动获取 Animator 组件
animator = GetComponent<Animator>();
if (animator == null)
{
Debug.LogError("Animator component not found on actor.");
}
}
public void PlayAnimation(string animationName)
{
if (animator != null)
{
animator.Play(animationName);
}
else
{
Debug.LogError("Animator not found on actor.");
}
}
public void InitializeAtSlot(Transform slot)
{
if (slot != null)
{
transform.position = slot.position;
transform.rotation = slot.rotation;
}
else
{
Debug.LogError("Slot transform is null.");
}
}
public void SetAnimationState(string stateName)
{
if (animator != null)
{
animator.SetTrigger(stateName);
Debug.Log("Trigger"+stateName);
}
else
{
Debug.LogError("Animator not found on actor.");
}
}
}