- Home /
Disable character control collision
I want to disable character control collision and want ALL other parts of my model to have a collision so the player can not run through the model. This script from FPS control does not do the trick and i'm rather stuck. Can someone help me rewrite this part so it could work?
Ty
function Die()
{
if (hideWhenDead)
{
gameObject.SetActive(false);
}
else
{
var colliders : Collider[] = gameObject.GetComponentsInChildren.<Collider>();
for (var i:int = 0; i < colliders.Length; i++)
{
if ((colliders[i] != null) && !colliders[i].isTrigger )
{
if( typeof( colliders[i] ) == CharacterController )
{
colliders[i].gameObject.SetActive(false);
//colliders[i].enabled = false;
}
else
{
colliders[i].gameObject.SetActive(false);
//GameObject.DestroyImmediate(colliders[i]);
//colliders[i].enabled = false;
}
}
}
}
}
Comment
Your answer
