Hello.
I’m trying to make my project recognize the Box Colliders of all of its children and enable them during the specific steps of a walking animation for one second, then disable them again, but Unity cannot find what I’m asking of it (NullReferenceException). Granted, the sound works perfectly fine during the trigger, unless the player/ camera happens to be facing away from what’s walking; but it cannot find the colliders at all.
Here’s the erroneous code I have. It’s simple, but I’m new as well:
var audioVolume = 1.0;
var collisionSoundEffect : AudioClip;
function playSound() {
audio.volume = audioVolume;
audio.clip = collisionSoundEffect;
audio.Play();
gameObject.GetComponentsInChildren(BoxCollider).collider.enabled = true;
yield WaitForSeconds(1);
gameObject.GetComponentsInChildren(BoxCollider).collider.enabled = false;
}