2026-06-12 리듬게임 (진행중)
This commit is contained in:
37
Assets/02_Scripts/Rhythm/RhythmProjectile.cs
Normal file
37
Assets/02_Scripts/Rhythm/RhythmProjectile.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using Hovl;
|
||||
using UnityEngine;
|
||||
|
||||
// Hovl의 HS_ProjectileMover(에셋)를 "수정하지 않고" 히트 이펙트를 코드로 터뜨리기 위한 서브클래스.
|
||||
// 핵심: protected 멤버(hit/hitPS/projectilePS/collided)는 '파생 클래스'에서는 접근 가능하다.
|
||||
// 그래서 에셋 원본은 그대로 두고, 충돌(Collision) 없이 판정 성공 시 Detonate()로 이펙트만 재생한다.
|
||||
public class RhythmProjectile : HS_ProjectileMover
|
||||
{
|
||||
// 판정 성공 시 호출. 노트가 곧 Destroy되어도 이펙트가 보이도록 노트에서 분리 후 재생.
|
||||
public void Detonate()
|
||||
{
|
||||
if (collided) return;
|
||||
collided = true;
|
||||
|
||||
// 날아가는 동안의 트레일 파티클은 정지
|
||||
if (projectilePS != null)
|
||||
projectilePS.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear);
|
||||
|
||||
// 히트 이펙트 컨테이너(없으면 파티클 본체)를 노트에서 떼어내 현재 위치에서 재생
|
||||
GameObject fx = hit != null ? hit : (hitPS != null ? hitPS.gameObject : null);
|
||||
if (fx == null) return;
|
||||
|
||||
fx.transform.SetParent(null, true);
|
||||
fx.transform.position = transform.position;
|
||||
fx.SetActive(true);
|
||||
|
||||
if (hitPS != null)
|
||||
{
|
||||
hitPS.Clear(true);
|
||||
hitPS.Play(true);
|
||||
}
|
||||
|
||||
// 재생이 끝나면 분리한 이펙트도 정리
|
||||
float life = hitPS != null ? hitPS.main.duration + hitPS.main.startLifetime.constantMax : 2f;
|
||||
Destroy(fx, life);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user