- Home /
OnTriggerEnter No effect
enter code herei have used capsule collider on the battery and checked IsTrigger box The code below is part of playercollision script where on collision i want the effects to take place but nothing is happening
function OnTriggerEnter(collisionInfo : Collider)
{
if(collisionInfo.gameObject.tag == "battery")
{
BatteryCollect.charge++;
audio.PlayOneShot(batteryCollect);
Destroy(collisionInfo.gameObject);
}
}
Can you please format the code that you are showing? Just click in the binary icon(code sample) and format the code that you are showing to us.
Answer by Stormizin · Dec 27, 2013 at 06:14 PM
Did you added a rigidbody into the mesh that you are trying to collide with your battery?
actually i made a silly mistake i forgot to tag the battery models as battery so the if clause never got executed its working now thank u
Your answer
Follow this Question
Related Questions
OnTriggerEnter Being Called On Unexpected Object 1 Answer
I'd like some help with my health / shooting (collision detection) 1 Answer
Collission and Trigger on Same object 0 Answers
Stacking mechanic (Parenting Prefab to another prefab on collision) 2 Answers
Change NavMesh Speed after collision/trigger just for 1 object 1 Answer