I have a box collider acting as a trigger, when the player enters this trigger i’d like to enable the box colliders of the 5 child objects I have, as well as their sprite renderers. This is what I have so far but it’s not quite right.
using UnityEngine;
using System.Collections;
public class EnableObject : MonoBehaviour {
private BoxCollider[] boxColliders;
private SpriteRenderer[] sR;
private bool run = false;
void Update()
{
if(run)
{
boxColliders = GetComponentsInChildren<BoxCollider>();
sR = GetComponentsInChildren<SpriteRenderer>();
boxColliders.enabled = true;
sR.enabled = true;
}
}
void OnTriggerEnter(Collider other)
{
if(other.GetComponent<Collider>().tag == "Player")
{
run = true;
}
}
}