Anykey
1
Hi,
I’m trying to detach an object from his parent when it’s not colliding anymore (it’s a rigidbody on a platform)
function OnCollisionStay (TheCollision : Collision) {
if(TheCollision.gameObject.tag == "Plateform"){
Debug.Log("NNNNNNNOOOOOOOOOO");
transform.parent = TheCollision.transform ;
}
}
function OnCollisionExit (TheCollision : Collision) {
if(TheCollision.gameObject.tag == "Plateform"){
Debug.Log("SSSSSSSSSSSSUUUUUU");
transform.parent = null;
}
}
Actually , the console is not even displaying SSSSUUUU when it’s not colliding anymore , i’ve tried with OnCollisionEnter instead of OnCollisionStay , but it doesn’t work at all and the object does not become the child of the platform when it collides with it
What can I do ???
Thanks for reading
Anykey
2
I’ve used a trigger as child of the platform instead of Collision with the platform itself and it works now
Anykey
3
function OnCollisionStay (hit : Collision) {
if(hit.gameObject.tag == “Plateform”){
transform.parent = TheCollision.transform ;
}
else{
transform.parent = null;
}
}
That should add you as a child under the platform and it should separate you from the platform when you are no longer on it.
Thank you so much OrangeLightning for answering this in another question