- Home /
Question by
el_kloklo · Mar 10, 2014 at 09:13 PM ·
physicscollidertransformignorecollision
ignorecollision return error
Hello All,
in anticipation of future collision with and object and his child, I have created this method :
public bool LoadPassenger(UnitScript NewPassenger) {
//we allow to reload existing passenger to reperform the physics action and so, notably at start call.
if((Passenger.Count<CrewActionByPriority.Count)||(Passenger.Contains(NewPassenger)==true))
{
Debug.Log(this.name+" load passenger "+NewPassenger);
if(Passenger.Contains(NewPassenger)==false)
Passenger.Add(NewPassenger);
//ignore collision of passenger with vehicle
foreach(Collider colliChar in this.GetComponents<Collider>())
{
foreach(Collider colliHit in NewPassenger.GetComponents<Collider>())
{
Physics.IgnoreCollision(colliHit,colliChar,true);
}
}
foreach(Transform child in transform)
{
foreach(Collider colliChar in this.GetComponents<Collider>())
{
foreach(Collider colliHit in NewPassenger.GetComponents<Collider>())
{
Physics.IgnoreCollision(colliHit,colliChar,true);
}
}
}
//do stuff
NewPassenger.transform.parent=this.transform;
return true;
}
return false;
}
But in game, it returns me this error message.
Ignore collision failed. Both colliders need to be activated when calling this IgnoreCollision
The Unitscript got a charactercollider attached onto it, and the parent caller and all his child got a cube collider attached, and I have set theseforeach calls in case one day an object got multiplecolliders.
I have searched a bit around and I do not know what to think.
Thanks for the help.
Comment
Your answer
Follow this Question
Related Questions
Physics.IgnoreCollision not working 0 Answers
Ignore Collision Temporarily 1 Answer
How to properly move a rigidbody/collider? 2 Answers