You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.3 KiB
54 lines
1.3 KiB
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
|
|
public class TrappedPerception : MonoBehaviour |
|
{ |
|
private List<GameObject> firemanList = new List<GameObject>(); |
|
RaycastHit hit; |
|
|
|
public List<GameObject> FiremanList |
|
{ |
|
get |
|
{ |
|
return firemanList; |
|
} |
|
} |
|
|
|
void Update() |
|
{ |
|
Ray ray = new Ray(transform.position, transform.forward); |
|
if (Physics.Raycast(ray, out hit)) |
|
{ |
|
if (hit.collider.tag == "fire") |
|
{ |
|
if (Vector3.Distance(transform.position, hit.point) < 10) |
|
{ |
|
Debug.Log(hit.collider.name); |
|
} |
|
} |
|
} |
|
} |
|
|
|
public void OnTriggerExit(Collider other) |
|
{ |
|
if (other.tag=="Player"&&firemanList.Contains(other.gameObject)) |
|
{ |
|
firemanList.Remove(other.gameObject); |
|
Debug.Log(other.name+"leave"); |
|
} |
|
} |
|
|
|
public void OnTriggerEnter(Collider other) |
|
{ |
|
if (other.tag == "Player" && !firemanList.Contains(other.gameObject)) |
|
{ |
|
firemanList.Add(other.gameObject); |
|
Debug.Log(other.name + "enter"); |
|
} |
|
if (GetComponent<TrappedMoveFree>()) |
|
{ |
|
GetComponent<TrappedMoveFree>().FireManNear = true; |
|
} |
|
} |
|
}
|
|
|