Auto-portal, but cooler
This commit is contained in:
@@ -4,24 +4,38 @@ using UnityEngine;
|
|||||||
|
|
||||||
public class Autoportal : MonoBehaviour
|
public class Autoportal : MonoBehaviour
|
||||||
{
|
{
|
||||||
public GameObject imposter;
|
private List<GameObject> imposters;
|
||||||
|
|
||||||
private OcclusionPortal portal;
|
private OcclusionPortal portal;
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
this.portal = this.GetComponent<OcclusionPortal>();
|
this.portal = this.GetComponent<OcclusionPortal>();
|
||||||
|
this.imposters = new List<GameObject>();
|
||||||
|
|
||||||
|
foreach(Transform child in this.transform)
|
||||||
|
{
|
||||||
|
this.imposters.Add(child.gameObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnTriggerEnter(Collider other)
|
private void OnTriggerEnter(Collider other)
|
||||||
{
|
{
|
||||||
this.portal.open = true;
|
this.portal.open = true;
|
||||||
this.imposter.SetActive(false);
|
|
||||||
|
foreach(GameObject imposter in this.imposters)
|
||||||
|
{
|
||||||
|
imposter.SetActive(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnTriggerExit(Collider other)
|
private void OnTriggerExit(Collider other)
|
||||||
{
|
{
|
||||||
this.portal.open = false;
|
this.portal.open = false;
|
||||||
this.imposter.SetActive(true);
|
|
||||||
|
foreach(GameObject imposter in this.imposters)
|
||||||
|
{
|
||||||
|
imposter.SetActive(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user