Addressing gameObject Parent

I have a door model which has three parts - door, frame, button. I have a script attached to the button so that when it’s pressed, the state of the door is checked and the appropriate animation needs to play - i.e. door opening or door closing.

Can anyone tell me how to address the button’s parent object?

e.g.

gameObject.parent.animation.Play(“opening”)

parent of an object is found through its transform.parent field.

hierarchies of objects are formed only through transform, gameobjects don’t know anything about hierarchy etc :slight_smile:

gameObject.transform.parent.animation.Play("opening");

And it’s working. Thanks very much for the quick reply :slight_smile: