23 lines
654 B
C#
23 lines
654 B
C#
namespace Marro.PacManUdon
|
|
{
|
|
using UdonSharp;
|
|
using UnityEngine;
|
|
|
|
public class Teleporter : UdonSharpBehaviour
|
|
{
|
|
[SerializeField] private Direction direction = Direction.Zero;
|
|
[SerializeField] private Transform target;
|
|
|
|
void OnTriggerEnter(Collider other)
|
|
{
|
|
GridMover gridMover = other.gameObject.GetComponent<GridMover>();
|
|
|
|
if (gridMover == null || gridMover.GetDirection() != direction)
|
|
{
|
|
return;
|
|
}
|
|
|
|
gridMover.SetPosition(gridMover.GetPosition() + (Vector2)(target.localPosition - transform.localPosition));
|
|
}
|
|
}
|
|
} |