Hello,
So I’m having a bit of a problem. I want to have a button that when clicked, will refocused the camera onto a different point of my human model. I’ve managed to get the camera to move, but it happens when I click anywhere on my game screen. I’m assuming this is because the button is a child of the parent canvas, which covers the screen.
My code is below:
#pragmastrict
vartarget : Camera;
varzoom : int = 20;
varnormal : int = 60;
varsmooth : float = 5;
privatevarisZoomed = false;
functionStart () {
}
functionUpdate () {
if (Input.GetMouseButtonDown(0)){ isZoomed = !isZoomed; }
{
{
//target.main.transform.Translate(1,1,1);
//target.fieldOfView = 20;
if(isZoomed == true)
{
target.fieldOfView = Mathf.Lerp(target.fieldOfView,zoom,Time.deltaTime*smooth);
}
else
{
target.fieldOfView = Mathf.Lerp(target.fieldOfView,normal,Time.deltaTime*smooth);
}
}
}
}
Could anyone point me in the right direction of how to achieve what I need it to?
Many thanks,