rabidus-test/Assets/BNG Framework/Scripts/Helpers/TeleportPlayerOnEnter.cs

21 lines
572 B
C#
Raw Permalink Normal View History

2023-07-24 16:38:13 +03:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace BNG {
public class TeleportPlayerOnEnter : MonoBehaviour {
public Transform TeleportDestination;
void OnTriggerEnter(Collider other) {
if(other.GetComponent<CharacterController>()) {
PlayerTeleport pt = other.transform.GetComponentInParent<PlayerTeleport>();
if(pt && TeleportDestination) {
pt.TeleportPlayerToTransform(TeleportDestination);
}
}
}
}
}