Hey everyone. I’m working on a main menu, and i’m trying to get it to move back and forth when you click certain buttons. When I click options and it moves to the options area, but when I try to hit back (They are both run under the same script), it stays put and doesn’t move back.
Here is the script i’m using:
var Selectsound : AudioClip;
var HoverSound : AudioClip;
var target: Transform;
var speed: float;
var Select : boolean = false;
function OnMouseEnter () {
audio.PlayOneShot(HoverSound, 0.7);
transform.renderer.material.color = Color.gray;
}
function OnMouseExit () {
transform.renderer.material.color = Color.white;
}
function OnMouseDown () {
Select = true;
transform.renderer.material.color = Color.cyan;
audio.clip = Selectsound;
audio.Play();
}
function Update () {
if(Select == true){
var step = speed * Time.deltaTime;
Camera.mainCamera.transform.position = Vector3.MoveTowards(Camera.mainCamera.transform.position, target.position, step);
}
}