- Home /
collider glitches (OnEnter, OnExit)
Hi there
I have some glitches I can not really retrace.
I have a Collider on my avatar. My avatar looks constantly at an object(the object stays within the collider).
But at random points of time the Colliders OnExit/OnEnter methods get called.
What could be the reason for that? Are there known problems with colliders?
thanks in advance
Answer by swisscoder · Oct 31, 2011 at 04:39 PM
Resolved it recently.
My problem was that I moved my code to another project, where I did not set up the colliding layers!
Therefor they kept beeing triggered from all possible colliders.
Was a quick fix, but not an obvious one, because its easy to forget about something you set up once (and then leave it).
Answer by Bunny83 · Oct 17, 2011 at 01:33 PM
Maybe another collider collides with your collider? How do you use the colliders? As triggers(isTrigger=true) i guess? Don't forget to attach a rigidbody to the moving object.
You could place a Debug.Log into the OnTriggerEnter / OnTriggerExit functions and print the name of the colliding object
I have a collection where I store the objects on OnTriggerEnter and remove them OnTriggerExit. The collider on my character has IsTrigger = true, the other colliders have IsTrigger = false. All Colliders are on a user layer of there own and I set up the layer collision matrix so that only colliders on the same layer can trigger OnTriggerEnter/OnTriggerExit. As I said the problems is, that for a short period the Object that triggered the OnEnter does exit and enter again, but there is no visible movement and no change in the transforms position.
Just discovered the Raycasts Hit Triggers option.. maybe that could cause this behaviour? have to look it up quickly
Your answer
Follow this Question
Related Questions
Make sure objects are not instantiated on each other 2 Answers
Unity 2D How can I detect collision with a Vector3? 2 Answers
Stop platforms spawning inside player 1 Answer
random spawn assigned prefab from collider 1 Answer
Internal collisions 1 Answer