Just to confirm that you are using 3D colliders? For 2D physics there’s different OnTriggerEnter2D(). Also OnTriggerEnter() executes only once, OnTriggerStay() executes all the time when inside trigger.
On other note about your code, sure it would do something when entering trigger, but you should control the door animation with other state variable. That if-clause for example “if(this.gameObject.transform.position == endPoint)”, it would enter that endPoint2 only 1 time, because the if will then be false again. You can do something like
if (state==0) {
transform....
// check if can change to state 1
} else if (state==1) {
transform....
// check if can change to state 2
} ... and so on.
Your ‘trigger’ should be a cube without the mesh renderer. When this cube is in front of the door and the player is in contact with it, then the door will open before the player hits the door (like sliding doors in real life).
This ‘trigger’ needs to have a RigidBody component, or your player needs to have one. You can enable isKinematic to keep it from moving.
Make sure this ‘trigger’ cube that is invisible (or whatever trigger you’re using) has isTrigger enabled on the collider.
In your script:
function OnTriggerEnter(other : Collider) {
Debug.Log("OPening door!"):
}
The main reason other : Collider is there is so you can use it in an if statement if you want to check if it’s the player via its tag or name etc.