LevelChange On MouseClick
I am trying to make a door that when you walk up to it and you press the mouse button, It will move to the next level. Right now I have a TriggerZone on the object and I am using the OnTriggerEnter function, but you can't but Input.GetMouseButtonUp(0); function in the OnTriggerEnter. I believe that it must go in the Update function. How can I make it so that I can put the triggerDetection in Update or put the Input.GetMouseButtonUp(0); in the OnTriggerEnter. Here is my code. I am using C#. using UnityEngine; using System.Collections;
public class DoorEnter : MonoBehaviour {
public GUIText TriggerText;
int MouseIsClicked;
void Start () {
TriggerText.text = " ";
}
void OnTriggerEnter2D (Collider2D other) {
if (Input.GetMouseButtonUp (0)) {
}
if (other.CompareTag("FloatingCastleBottom")) {
TriggerText.text = "Go into the Castle";
if (Input.GetMouseButtonUp(0)) {
Application.LoadLevel("UnderWater");
}
}
}
void OnTriggerExit2D (Collider2D other) {
TriggerText.text = " ";
}
}
Thanks
Your answer
Follow this Question
Related Questions
Unity physics Help Implementing Real Life Physics in Jumping System C# 2 Answers
Invisible objects appear after collision 2 Answers
why isnt my code working, 2 Answers
ANIMATION TRIGGER DOESN'T PLAY 1 Answer
Stop OnCollisionEnter executing twice on one collider yet atleast once PER collider? 1 Answer