I am trying to make a "Button" that will open a door in a 2d enviroment. I get an error on the triggerScript saying "the associated script can not be loaded. please fix any compile errors and assign a valid script"
I have made a sprite called TriggerObject that has the triggerTrigger script bellow.
using UnityEngine;
using System.Collections;
public class triggerTrigger : MonoBehaviour
{
public static bool isTrigger = false;
public void OnTriggerEnter2D(Collider2D other)
{
if (isTrigger == false)
{
Debug.Log("Collided!");
isTrigger = true;
}
}
public void OnTriggerExit2D(Collider2D other)
{
if (isTrigger == true)
{
Debug.Log("Exit!");
isTrigger = false;
}
}
}
Ive also got a door called Door1 with the script down below
using UnityEngine;
using System.Collections;
public class Trigger : MonoBehaviour
{
Vector3 tempPos;
public void Start()
{
GameObject triggerObject = GameObject.Find("TriggerObject");
triggerTrigger TriggerTrigger = triggerObject.GetComponent();
Debug.Log("TRIGGER INITIALIZED");
}
public void Update()
{
if (triggerTrigger.isTrigger == true)
{
Debug.Log("MOVING");
tempPos = transform.position;
tempPos.y -= 0.05f;
transform.position = tempPos;
}
}
}
If i could get some advice, that would be perfect!
↧