C# Accessing another objects script values

Hi,
I’m new to using Unity. So far I’ve managed to learn quite a lot, but I’ve come across a problem, which i’ve attempted to look for solutions although none seem to work for me.

I have three objects. The player, a door, and a collision object.
What i’m aiming for is, when a player walks over the collision object, the door will close.

Names of my objects:

  1. Player = Player
  2. Collision object = colision
  3. Door = frontdoor

My door also has a prefab which is called innerdoor which will be the object with an animation to open. This innerdoor object has been referenced by frontdoor by a script value. The value is called “doorInside”.

I’ve tried the following

Frontdoor = GameObject.Find ("frontdoor");
Innerdoor = GameObject.Find (Frontdoor.doorInside);

Frontdoor.doorInside.GetComponent<Animation>().Play("Close");

So Frontdoor is the name of the whole door object. doorInside is a value from a script which references the actual object that the animation is on which is called innerdoor

Sorry if this has been a terrible explanation, hopefully someone can help though.

Thankyou

First make sure your player has a rigidbody component & collider.

Also show us the complete copy of your OnTriggerEnter() function which might be on your trigger of the door.