- Home /
Smooth Camera Movement Question
I want to make the camera get close to both objects when they reach a certain range and i want to use Lerp or something like that so the camera movement goes smoothly This is how im trying to do it
function Update () {
var startPos :Vector3 =Vector3(
(point1.transform.position.x + point2.transform.position.x)/2,
(point1.transform.position.y + point2.transform.position.y)/2,
(point1.transform.position.z + point2.transform.position.z)/2);
var endPos :Vector3= Vector3(
(point1.transform.position.x + point2.transform.position.x)/2,
(point1.transform.position.y + point2.transform.position.y)/2,
(point1.transform.position.z + point2.transform.position.z)+500);
if(Vector3.Distance(point1.position,point2.position)<=distancemin)
{
Vector3.Lerp(startPos,endPos,Time.deltaTime*0.5);
Debug.Log("omg");
}
}
function Awake() {
transform.position =(point1.transform.position+ point2.transform.position)/2;
}
plz any help is REALLY appreciated ,It doesnt have to be with Lerp but i really want it to be in a way that the movement is smooth
please format your code so its easier to read.... just select your code and hit the format button
Your answer
![](https://koobas.hobune.stream/wayback/20220613071205im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
moving between two points over time 1 Answer
How can I Vector3 Slerp or Lerp locally? 3 Answers
make my gameobject lerp between points more smoothly 0 Answers
Vector3.MoveTowards and Quaternion.RotateTowards 1 Answer
Moving object with vector3 lerp 0 Answers