I am attempting to LERP a camera between two set Vector3 coordinates, using an onClick event on a GUI button. I have accomplished this task, with one set back. I must continually click the GUI button to move the camera along its path, until I reach the target position. Instead, I want the player to click the associated camera button once and move to the target position. As an asset designer/3D modeler, I am not proficient with coding at all, so forgive my inexperience. Here is my camera movement script, written in C#.
using UnityEngine;
using System.Collections;
public class CameraMovement : MonoBehaviour {
private Vector3 Target;
private Vector3 cameraStartPosition;
private bool isLerping;
public float Speed;
public void CameraPosition1()
{
isLerping = true;
cameraStartPosition = transform.position;
Target = new Vector3(0, 0, 0);
}
public void CameraPosition2()
{
isLerping = true;
cameraStartPosition = transform.position;
Target = new Vector3(24, 0, 0);
}
void FixedUpdate()
{
if (isLerping) {
transform.position = Vector3.Lerp (cameraStartPosition, Target, Speed * Time.deltaTime);
}
}
Thank you in advance for your assistance.