유나 드래곤폼 추가중
This commit is contained in:
@@ -5,6 +5,9 @@ public class NPCController : MonoBehaviour
|
||||
private Animator _anim;
|
||||
[SerializeField] private int _defaultAnimNo;
|
||||
|
||||
[Tooltip("애니메이션 이벤트로 켜고 끌 이펙트들 — 이벤트의 Int 파라미터가 이 목록의 인덱스")]
|
||||
[SerializeField] private GameObject[] _animationEffects;
|
||||
|
||||
private static readonly int _speedHash = Animator.StringToHash("Speed");
|
||||
|
||||
private Vector3 _lastPosition;
|
||||
@@ -47,4 +50,35 @@ private void LateUpdate()
|
||||
_smoothedSpeed = Mathf.Lerp(_smoothedSpeed, delta.magnitude / Time.deltaTime, 10f * Time.deltaTime);
|
||||
_anim.SetFloat(_speedHash, _smoothedSpeed);
|
||||
}
|
||||
|
||||
// 애니메이션 이벤트용 — 등록된 이펙트 활성화 + 재생 (Int 파라미터 = _animationEffects 인덱스)
|
||||
public void OnAnimationEffect(int effectNo)
|
||||
{
|
||||
var effect = GetEffect(effectNo);
|
||||
if (effect == null) return;
|
||||
|
||||
effect.SetActive(true);
|
||||
|
||||
// 이미 켜져 있는 상태에서 이벤트가 또 와도 처음부터 다시 재생되도록
|
||||
var ps = effect.GetComponentInChildren<ParticleSystem>();
|
||||
if (ps != null) ps.Play(withChildren: true);
|
||||
}
|
||||
|
||||
// 애니메이션 이벤트용 — 등록된 이펙트 비활성화
|
||||
public void OffAnimationEffect(int effectNo)
|
||||
{
|
||||
var effect = GetEffect(effectNo);
|
||||
if (effect != null) effect.SetActive(false);
|
||||
}
|
||||
|
||||
private GameObject GetEffect(int effectNo)
|
||||
{
|
||||
if (_animationEffects == null || effectNo < 0 || effectNo >= _animationEffects.Length
|
||||
|| _animationEffects[effectNo] == null)
|
||||
{
|
||||
Debug.LogWarning($"[NPCController] 등록되지 않은 이펙트 번호: {effectNo} ({name})");
|
||||
return null;
|
||||
}
|
||||
return _animationEffects[effectNo];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user