123456789101112131415161718192021222324252627282930313233343536373839 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- namespace TrafficSimulation{
- public class PresetTrigger : MonoBehaviour
- {
- public bool isTriggered;
- public string triggerTag;
- private GameObject lastCollider;
- // Start is called before the first frame update
- void Start()
- {
- this.isTriggered = false;
- }
- // Update is called once per frame
- void Update()
- {
-
- }
- private void OnTriggerEnter(Collider other) {
- if(other.gameObject.tag == this.triggerTag){
- this.isTriggered = true;
- this.lastCollider = other.gameObject;
- }
- }
- public GameObject getLastCollider(){
- return this.lastCollider;
- }
- public bool checkLastTrigger(){
- bool currentState = this.isTriggered;
- this.isTriggered = false;
- return currentState;
- }
- }
- }
|