Hello all’
I am a new user of Unity
I am trying to get a door to open when approached by a player
I have used a doorframe and door from a free dungeon package and tried to follow a tutorial from memory.
I have a C# script and I have debug.log statements to track what is working and whats not.
The door opens and closes when I det the variable in the animation window.
The script detects the trigger event and sets the variable but no animation happens.
I have probably missed some step.
Note: the anims and script and box collider are all attached to the door.
I realize that will move the collider when the door opens.
Thanks for assistance .
Here is the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Door_control : MonoBehaviour {
Animator anim ;
public bool p_door_open;
// Use this for initialization
void Start ()
{
Debug.Log ("Start");
p_door_open = false;
anim = GetComponent<Animator>();
}
void OnTriggerEnter(Collider col)
{
Debug.Log ("collider enter");
Debug.Log (col.gameObject.tag);
if (col.gameObject.tag == "Player")
{
Debug.Log ("setting bool");
p_door_open = true;
}
}
void OnTriggerExit(Collider col)
{
Debug.Log ("collider exit");
}
// Update is called once per frame
void Update () {
}
}