- Home /
Returned string values of thisCollider.name and otherCollider.name swap
The returned string values of thisCollider.name and otherCollider.name swap with each other in a seemingly random and inconsistent manner.
I have a simple set up. I have a character that consists of a parent GameObject with a rigidbody and a controller script component attached, a child GameObject with a collider component for the feet and a second child GameObject with a collider component for the body. Neither of the children have rigidbody components.
There is a completely separate floor GameObject with a collider component, again this does not have a rigidbody component as it is not necessary.
The parent GameObject is named "Parent"
The child feet GameObject is named "Feet"
The child body GameObject is named "Body"
The completely separate floor GameObject is name "Floor"
The following script is attached to the parent GameObject:
function OnCollisionEnter(theCollision : Collision)
{
Debug.Log("The parent object's name is ... " + gameObject.name);
for (var contact : ContactPoint in theCollision.contacts)
{
Debug.Log("A collider on a child gameobject named" + contact.thisCollider.name + " has hit a collider on a separate, completely non-related gameobject named " + contact.otherCollider.name);
}
}
When the character is standing on the floor, jumps into the air and land onto the floor again, sometimes the Debug.Log reports the following:
A collider on a child gameobject named Feet has hit a collider on a separate, completely non-related gameobject named Floor
But sometimes it reports the following:
A collider on a child gameobject named Floor has hit a collider on a separate, completely non-related gameobject named Feet
It seems to swap thisCollider.name and otherCollider.name with each other in a seemingly random and inconsistent manner.
Anyone know what might cause this to happen?
One thing I've noticed is that it swaps when re-loading a scene. e.g. I've got a scene where it's always one way around, but if I leave the scene and come back, it's always the other way around.
Seems that isn't not just switching scenes. $$anonymous$$ore discussion here: http://forum.unity3d.com/threads/97745-Collision-methods-List-of-contact-points-is-mixed-up-incorrect
Your answer
Follow this Question
Related Questions
Find nearest contact point inside trigger 2 Answers
How to figure out the contact point of OnTriggerEnter? 1 Answer
Raycasts ignoring colliders based on Collider Name 2 Answers
How to Image Swap on Collision 1 Answer
object name disappearing!! 1 Answer