Hey there!! I have been following a tutorial on Youtube on how to make a “holographic UI” appear on a distance trigger. I will link the tutorial here:
However this script does not seem to allow me to create the trigger event. Nothing happens, the animation just loops through.
public float minDistance = 2;
public bool show = false;
protected Animator[ ] children;
void Start () {
children = GetComponentsInChildren();
for (int a = 0; a < children.Length; a++)
{
children[a].SetBool(“Show”, true);
}
}
// Update is called once per frame
void Update () {
Vector3 delta = Camera.main.transform.position - transform.position;
if (delta.magnitude < minDistance)
{
if (show) return;
show = true;
for (int a = 0; a < children.Length; a++)
{
children[a].SetBool(“Show”,true);
}
}
else
{
if (!show) return;
show = false;
for (int a = 0; a < children.Length; a++)
{
children[a].SetBool(“Show”, false);
}
}
}
}
I am used the latest version of unity.
Whats wrong here?