50 lines
1.0 KiB
C#
50 lines
1.0 KiB
C#
using UnityEngine;
|
|
|
|
public class INT_TalkingAnimation : MonoBehaviour
|
|
{
|
|
public INT_Chat TargetChat;
|
|
|
|
[SerializeField]
|
|
private Animator TargetAnimator;
|
|
|
|
[Header("Used for more basic NPCs, that don't usually move")]
|
|
[SerializeField]
|
|
private string TalkAnimationName;
|
|
|
|
[SerializeField]
|
|
private string IdleAnimationName;
|
|
|
|
[Header("For more advanced NPCs like Papyrus or Toriel")]
|
|
[SerializeField]
|
|
private bool UseTalkBool;
|
|
|
|
[SerializeField]
|
|
private string TalkBoolName;
|
|
|
|
private void Update()
|
|
{
|
|
if (TargetChat.CurrentlyBeingUsed)
|
|
{
|
|
if (TalkAnimationName != null && !UseTalkBool)
|
|
{
|
|
TargetAnimator.Play(TalkAnimationName);
|
|
}
|
|
if (TalkBoolName != null && UseTalkBool)
|
|
{
|
|
TargetAnimator.SetBool(TalkBoolName, value: true);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (IdleAnimationName != null && !UseTalkBool)
|
|
{
|
|
TargetAnimator.Play(IdleAnimationName);
|
|
}
|
|
if (TalkBoolName != null && UseTalkBool)
|
|
{
|
|
TargetAnimator.SetBool(TalkBoolName, value: false);
|
|
}
|
|
}
|
|
}
|
|
}
|