ThreeKingdomsSlingshot/Assets/Scripts/Runtime/Skills/SkillVfxFacing.cs

38 lines
1.1 KiB
C#
Raw Normal View History

using UnityEngine;
namespace TKS
{
/// <summary>
/// 유닛에 붙은 반복 이펙트(상태 이상·기운)를 유닛이 바라보는 쪽 기준 자리에 둔다(표 skill_vfx.csv b_face 1 + f_dx ·
/// PD 2026-11-11 「출혈 이펙트는 유닛보다 하단 레이어 · 유닛의 바라보는 방향 우측 상단 위치」):
/// f_dx 양수 = 바라보는 쪽(오른쪽을 보면 오른쪽 · 왼쪽을 보면 왼쪽) — 유닛이 돌아서면 따라서 옮긴다.
/// </summary>
public class SkillVfxFacing : MonoBehaviour
{
UnitView view;
float baseX;
public void Init(UnitView v)
{
view = v;
baseX = transform.localPosition.x;
Apply();
}
void LateUpdate()
{
Apply();
}
void Apply()
{
if (view == null) return;
var p = transform.localPosition;
float x = view.FacingLeft ? -baseX : baseX;
if (Mathf.Abs(p.x - x) < 1e-4f) return;
p.x = x;
transform.localPosition = p;
}
}
}