Welcome to the forums!
When sharing code, [please use code tags]( Using code tags properly page-2#post-3330632). It makes reading the code much easier, retains formatting, and automatically adds links to methods in the API documentation. I’ll do your first one for you for free. After that, I start charging.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class open : MonoBehaviour {
public Animator anim;
// Use this for initialization
void Start () {
anim = GetComponent<Animator>();
}
// Update is called once per frame
void OnCollisionEnter(Collision col) {
if (Input.GetKeyDown("mouse 0"))
if (col.gameObject.name == "one_open") {
anim.Play("door");
}
}
}
This one’s an easy one to identify. If you look at the documentation for OnCollisionEnter, you’ll see it says:
And if we look at Input.GetKeyDown:
This means that OnCollisionEnter fires only on the frame where the object first collides with the other object. Similarly, Input.GetKeyDown happens on the frame where the user starts pressing a button. So the only way you’ll see that code run is if, on the same frame, the objects collide, the user starts pressing the key (incidentally, you probably want KeyCode.Mouse0 instead), and the object is named “one_open”. Since the timing of that is pretty unlikely, I encourage you to rethink the conditions upon which you want the door animation to trigger.
Think it through a bit yourself armed with the new information I’ve given. If you still can’t figure it out, let me know and I’ll push you further in the right direction.
Good luck!