I'm using a ray cast on my menu screen to make an action when the screen is clicked. however the code is performing when the mouse hovers over it not when the mouse is clicked! Code (csharp): public class InterLevelScript : MonoBehaviour { public bool audioStop; public GameObject arrow; public GameObject nails; public GameObject cement; // Use this for initialization void Start () { } // Update is called once per frame public void Update () { if(Application.loadedLevel==(1)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit = new RaycastHit(); if (Physics.Raycast(ray, out hit)) { if (hit.collider.gameObject.name=="Arrow") { arrow.active=false; nails.active=true; } if (hit.collider.gameObject.name=="Nails") { nails.active=false; cement.active=true; } if (hit.collider.gameObject.name=="Cement") { Application.LoadLevel(2); } } } if(audioStop==true) { AudioListener.pause = true; } if(audioStop==false) { AudioListener.pause = false; } } }
You will need to add a simple if before you Raycast, something like this: Code (csharp): if (Input.GetMouseButtonUp(0)) { // do raycast stuff } http://unity3d.com/support/documentation/ScriptReference/Input.GetMouseButtonUp.html