- Home /
Trigger via Collider
Hello,
I have tested a script that triggers an animation via a collider. And it worked pretty well. However, when i put the same script on my character, wich has a rigidbody. It doesn't work. I changed the tags and names. It looks ok to me. but it just doesn't respond. Even the print-message don't work.
I also tried to add an capsule-collider. But that doesn't work either. Anyone had the same problem? I can't figure out what's going wrong. I DO get the message "NullreferenceExecption. But i can't see what's wrong. Any idea's?
You'll need to post the code - NullReferenceException means you're doing something on an object which hasn't been assigned to, which is usually wrong
I just got the detection working. turned out i had the "target" on my script set to the model. But when i put it to "None" it worked fine. I'm sorry i posted this question for nothing, but maybe it can help out others..
Answer by Ashkan_gc · Jul 17, 2010 at 04:04 PM
many times the problem is not where you think. the other parts of the code has problems. if users post their codes it can be detected by others.
sometimes when you have rigidbodies your colliders are not trigger (i.e their is trigger is off) so OnTriggerEnter don't work and you should use OnCollisionEnter or make the collider a trigger.
that makes sense.. Thanks !! :) i'll keep this in $$anonymous$$d!