I have a camera that follows a ball and move along the X axis only. When the ball reaches this one area I want my camera to zoom out by -10 coordinates so it shows further away but as I am new to coding my attempts have been in vain.
Upon researching this is I’ve found snippets of information relating to other things and tried to compile them but to no avail I’m at a loss.
Edited code -
var target : Transform; //Variable for the position of an item
var distance = -10;
var lift = 1.5;
function Update ()
{
transform.position = target.position + Vector3(0, lift, distance); //Camera position should be equal to target position with the variables added on
transform.LookAt (target); //Always look at target
}
function OnTriggerEnter (collided : Collider)
{
if (collided.gameObject.tag == "ZoomOut")
{
Debug.Log("Zoom");
distance = distance * 10;
}
}
The debug.log doesnt show even though the collider is set a trigger and tagged as “ZoomOut” and the distance doesnt change.
Thanks for the help everyone I can’t seem to figure this out so I’m going to rewrite using a different method.