Who calls OnCollisionExit?
Hi everyone,
I'm working with motion controllers and I want to develop the Rubber Band Method for my thesis to backtrack my hand (not crossing) when colliding with walls.
I have a Sphere collidere for each finger and the rigidbody on the root gameobject. At first I developed a script for each collider but it wont be called because the rigidbody is on the root transform. After a while I tried to use a single script while saving all the ID of the colliders and for the OnCollisionEnter and OnCollisionStay I can understand which collider called the event (because I check the istanceID from the colliders of the contact point) BUT with che OnCollisionExit I do not have any contact point, so I cannot understand which of my colliders called the OnCollisionExit.
any help will be appreciated.
Answer by hexagonius · Oct 31, 2015 at 10:36 AM
OnCollisionExit provides the same information as OnCollisionEnter does. I just checked with code I wrote a while ago that checks contactpoints in OnCollisionExit and it worked.
@hexagonius my Debug.Log(hit.contacts.Length); return a zero. is it weird so?
Answer by iferoporefi · Oct 31, 2015 at 01:18 PM
http://answers.unity3d.com/questions/914908/u5-no-contactpoints-in-oncollisionexit.html
from this answer it seems like that there is no chance to get those contact points.
@hexagonius : If your old script is from unity 4.6 then you are right. It seems like that from unity 5 the OnCollisionExit does not return any contact point.
Thanks for pointing that out. They should really stop messing with working stuff all the time... maybe tracking colliders on enter and keep comparing in stay while checking in FixedUpdate if stay was called last time (is not if no more colliders) might give a solid opportunity to fire your own exit.
@hexagonius I've tried before but the problem is that I have multiple colliders and sometimes the OnCollisionStay does not give me back the one that I really need
It would be great if they fix this issue because it would be very useful
Answer by Brandon529 · Apr 20, 2018 at 05:50 PM
i just posted an answer to all your guys' problems on the link @iferoporefi shared, even tho im 3 years late.