private var doorIsOpen : boolean = false;
private var doorTimer : float = 0.0;
private var currentDoor : GameObject;
var doorOpenTime : float = 3.0;
var doorOpenSound : AudioClip;
var doorShutSound : AudioClip;
function OpenDoor (door : GameObject)
{
doorIsOpen = true;
door.audio.PlayOneShot(doorOpenSound);
door.transform.parent.animation.Play("doorOpen");
}
function OnControllerColliderHit (hit : ControllerColliderHit)
{
if(hit.gameObject.tag == "playerDoor" && doorIsOpen == false)
{
OpenDoor(hit.gameObject);
}
}
this is supposed to play a sound when my character collides with a door but it doesn’t i can’t understand why
Take it through simple steps;
verify first with a bit of debug that your code is reaching OnControllerColliderHit, then reaching OpenDoor(hit.gameObject);
Also confirm that it can play door.transform.parent.animation.Play(“doorOpen”); (and make a sound in normal code rather than conditional)
From the code snippet it may be that your “playerDoor” definition is incorrect elsewhere