- Home /
Inconsistent Trigger events
i'm developing a game for android, and i have problems with triggers, i want to do certain actions if a character touches certaion spots, but the OnTriggerEnter function gets called quite randomly.My basic setup is a non-static animated character with rigidbody and a capsule collider, and other non-static objects, with box triggers on them, usually they intersect for 5-10 frames or more and yet sometimes the function gets called and sometimes not
A concrete situation: i attached box triggers to my characters feet and have a runnning animation, OnTriggerEnter i instantiate a footprint, sometimes he can step 3 times consequitively leaving a footprint behind, and sometimes he can take 5 steps without leaving a single one, the animation is looped and quite symetric (same penetration values) and the trigger and the collider intersect for 5 frames at least, and the terrain is absolutely flat (made out of box colliders)
it also happens in other situations, the only temporary fix i found is raycasting, but its not to convenient to use
$$anonymous$$aybe a bit off-topic, but if are using $$anonymous$$ecanim for animation system, then you can use curves to achieve exactly what you are looking for.
Using the $$anonymous$$ecanim animation system, you can trigger different events using the curve values. Say, you want foot step sound, you can do that by drawing a simple curve according to the animation and add sound according to the curve values. And with this system you can do foot prints as well. :)
Further reading >>>
http://unity3d.com/unity/animation
http://docs.unity3d.com/Documentation/$$anonymous$$anual/$$anonymous$$ecanimAnimationSystem.html
http://video.unity3d.com/video/7362044/unity-40-mecanim-animation-tutorial
oh you meant the footprints, thanks i never thought of that, though i don't have Unity Pro currently, so can't do it with curves, but now you mention, i know when the foot touches the ground, so i can use Animator.normalizedtime to spawn my footprints. Even so thats one problem out of the way. Thanks!
Answer by TheShadowblast123 · Dec 31, 2013 at 09:33 AM
I found OnTriggerEnter to Always be the "glitchy one" you could use OnCollisionEnter and turn off the collider off imidately afterwards from the type of game it sounds like your making
it's not a viable solution for my game, and even if they are not used as triggers the problem remains
Your answer
Follow this Question
Related Questions
More realistic physics? 0 Answers
Triggers not being called 2 Answers
Ignore collisions with self but still trigger with self 2 Answers