Hi All,
So hopefully this is an easy question for someone! I have the following simple script that changes the position of the camera based on a key press.
private Vector3 newPosition;
void Awake ()
{
newPosition = transform.position;
}
void Update ()
{
PositionChanging();
}
void PositionChanging ()
{
Vector3 positionA = new Vector3(-50, 3, 0);
Vector3 positionB = new Vector3(500 , 3, 0);
if(Input.GetKeyDown(KeyCode.Q))
newPosition = positionA;
if(Input.GetKeyDown(KeyCode.E))
newPosition = positionB;
transform.position = newPosition;
}
}
I would like to change this so that the two positions are controlled by two UI buttons i have created using the Unity 4.6 UI. I assume i change the “Input.GetKeyDown” parts of the code? Or do i call it through the “onClick” field in the button itself?
Any help is gratefully received. It’s been driving me mad…
Thanks.
Paul