i have a chair that is animated and ends up hitting a wall, i have a box collider when the chair hits but the audio doesnt want to play, i have tried doing it a few ways but it wont work. any ideas? thanks
#pragma strict
var myClip : AudioClip;
function OnTriggerEnter (other : Collider) {
if(other.tag == "chair"){
audio.PlayOneShot(myClip);
}
}
if the chair is tagged in the inspector as a chair i do not see a problem but if the chair is the name of the object then change tag to name .disclaimer this could be wrong.
Since it’s not logging inside the if, either the collision is not triggering (try debugging outside the if to see if it logs) - in which case you have to make sure that one of the object has a rigidbody, both objects have colliders, the colliders are marked as trigger, and that they’re 3d colliders and not 2d colliders.
If it is logging, then the problem is with the tag checking, the tag of the object you’re colliding with might not be “chair”.
ive set it to a rigid body and now it works but only if it falls on the collider, if i try and freeze the y axis it does not work, any ideas? thank you
ok, ive got a chair that is animated and when it finishes playing it hits in to the wall, and on that wall where the animation finishes is a box collider. i want a sound to play when the chair hits that box collider, if i make the box collider a rigidbody it falls through the map, but if i move the box collider above the chair and it falls on to the chair it makes the sound i want, but if i put it back in the position i want it and uncheck gravity or freeze the axis, the sound will not play. you with me now?
yeah i have got both of them
– ryisnellyive just tried it with Debug.Log and it was not logged
– ryisnellyif i change it change it to look for player as tag then it works
– ryisnelly