I have an object
Hand, with a rigid body attached to it. In every
Update() call, the user's hand controller rotation and position are tracked.
In my scene, there is an object
Pin, with a mesh collider attached to it.
OnTriggerEnter() (inside the
Pin becomes re-parented to
Pin's original parent is something else.)
My scene also contains other objects with colliders. However, these other objects do not get re-parented -- only
Once this re-parenting takes place,
OnTriggerExit() (in the
Hand class) is called immediately. This is surprising to me -- I had expected
OnTriggerStay() (in the
Hand class) to be invoked instead, since
Hand is still in contact with
Is such behaviour by design? Is there an elegant way of working around such behaviour?
In response to this comment:
Does the pin object have a parent before it becomes a part of the hand?
Yes. As mentioned in my post,
Pin's original parent is something else.
Or is it placed inside another collider? And does the pin leave any of these collider areas when the parenting takes place?
As mentioned in my post,
Pin itself has a mesh collider component attached to it. Perhaps I am not understanding the question correctly...
You can prevent the hand's script from getting this OnTriggerExit by adding a seperate rigidbody to the pin.
I added a separate rigid body to the pin (setting
OnTriggerExit() inside the
Hand class is still called immediately after
Pin gets re-parented.
Pin's original parent (before it gets re-parented to
Hand) does not itself have a collider component.
OnTriggerExit(Collider collider)gets called immediately after the re-parenting takes place, the
colliderargument passed to the method is the