I'm trying to write some code so that when a gameObject enters a Trigger, it parents that gameObject to the triggers own parent. However, I'm having some difficulty accessing the Transform of said object in my code. Here's some examples of what I've tried:
function OnTriggerEnter (other : Collider){
if (other.transform.tag == "Moveable")
{
other.transform.parent = transform.parent;
}
}
And:
var otherTrans;
function OnTriggerEnter (other : Collider){
if (other.transform.tag == "Moveable")
{
otherTrans = other.transform;
otherTrans.parent = transform.parent;
}
}
I've tried a few other things too, but they're all variations on this. I've tried looking through the script references for inherited members, but I still can't find a way. What is the exact set of inherited members I need, or does my code need changed?
Thanks
P.S. all the colliders which it would pick up are rigidbodies.