Добавлен гудок машинам
This commit is contained in:
31
Assets/CarBipScript.cs
Normal file
31
Assets/CarBipScript.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class CarBipScript : MonoBehaviour
|
||||
{
|
||||
[HideInInspector]
|
||||
public UnityEvent<HitDetectorScript> PlayerEntered = new UnityEvent<HitDetectorScript>();
|
||||
|
||||
[HideInInspector]
|
||||
public UnityEvent<HitDetectorScript> PlayerExited = new UnityEvent<HitDetectorScript>();
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.gameObject.tag == "Player")
|
||||
{
|
||||
Debug.Log("Player Enter");
|
||||
HitDetectorScript hit = other.GetComponent<HitDetectorScript>();
|
||||
PlayerEntered.Invoke(hit);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
if (other.gameObject.tag == "Player")
|
||||
{
|
||||
Debug.Log("Player Exit");
|
||||
HitDetectorScript hit = other.GetComponent<HitDetectorScript>();
|
||||
PlayerExited.Invoke(hit);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user