My Code:
using UnityEngine;
using System.Collections;
public class Door_MAnager : MonoBehaviour
{
private bool open = false;
private bool GUIshow = false;
private Vector3 direction;
public float lenght;
private Vector3 spawn;
public GameObject door;
private RaycastHit hit;
void Start()
{
spawn = GameObject.Find("FPV_Final").GetComponent<Living_conditions>().spawn;
}
void Update ()
{
direction = transform.TransformDirection(Vector3.forward);
if (Input.GetKeyDown ("escape"))
{
Application.Quit ();
}
else if (Physics.Raycast (spawn, direction, lenght))
{
if (hit.collider.gameObject.tag == "Door")
{
GUIshow = true;
if (Input.GetKeyDown ("e") && open == false)
{
door.GetComponent<Animation> ().Play ("OpenDoor");
open = true;
GUIshow = false;
}
else if (Input.GetKeyDown ("e") && open == true)
{
door.GetComponent<Animation> ().Play ("CloseDoor");
open = false;
GUIshow = false;
}
}
}
else
{
GUIshow = false;
}
}
void OnGUI()
{
if(GUIshow == true && open == false)
{
GUI.Box(new Rect(100, 25, Screen.width / 2, Screen.height / 2), "Press E to open door");
}
}
}
my Problem:
In the Game NOTHING happens. no errors, no opening or closing doors, no animation being played