problem with lerp scripting...

am doing a small work in which am using lerp. The script is as below the error i get are

Assets/Scripts/camera.cs(33,68): error CS1502: The best overloaded method match for UnityEngine.Vector3.Lerp(UnityEngine.Vector3, UnityEngine.Vector3, float)' has some invalid arguments and Assets/Scripts/camera.cs(33,68): error CS1503: Argument #1’ cannot convert UnityEngine.Transform' expression to type UnityEngine.Vector3’

icouldn’t able to figure out the problem.

using UnityEngine;
using System.Collections;

public class camera : MonoBehaviour {
	
	public Transform targetPoint;
	public Transform startPoint;
	
	public GameObject cameraObject;
	
	void Start () 
	{
		EventManager._instance._buttonClick+=OnButtonClick;
		//inventry_item1.renderer.enabled = false;
	}
	
	void OnDisable()
	{
		EventManager._instance._buttonClick-=OnButtonClick;
		print ("event removed");
	}
		
	// Update is called once per frame
	void Update () {
	
	}
	
	void OnButtonClick(GameObject obj)
	{
		if(obj.name == "item_1")
		{
		      cameraObject.transform.position = Vector3.Lerp(startPoint, targetPoint, 2.0f);
		}
	}
}

need help.

You can not perform a Lerp in a one hit function. It must be used in the Update loop as the function needs to be called repeatedly with a gradually varying t value.

Move the if(){Lerp} to the Update and in OnButtonClick set a Lerping true/false. Use this boolean as your argument for your if statement.

t = 0 represents the From field

t = 1 represents the To field

Between 0 and 1 is a scaled value between 0 and 1

Read the reference

Lerp for 1 value

Lerp for Vector