Files
zeling_v2/Assets/Scripts/World/PhantomInteractable.cs
2026-05-13 09:19:54 +08:00

24 lines
695 B
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using UnityEngine;
namespace BaseGames.World
{
/// <summary>
/// 幻影可交互机关。继承 DirectionalInteractable额外响应 PhantomBody 层(太虚斩形态)。
/// </summary>
public class PhantomInteractable : DirectionalInteractable
{
private int _phantomBodyLayer;
private void Awake() => _phantomBodyLayer = LayerMask.NameToLayer("PhantomBody");
private void OnTriggerEnter2D(Collider2D other)
{
bool isPlayer = other.CompareTag("Player");
bool isPhantom = other.gameObject.layer == _phantomBodyLayer;
if (!isPlayer && !isPhantom) return;
TryActivate();
}
}
}