- Home /
Camera Movement (One Position to Another)
I just got into Unity a few days ago and am having a problem with the camera. I was trying to make a script that would have the camera go from one position to the next. My only problem is I'm horrible with Javascript/C#.
I do have a script from someone else but can't get it to work. Can you help?
function MoveObject (thisTransform : Transform, startPos : Vector3, endPos : Vector3, time : float) {
var i = 0.0;
var rate = 1.0/time;
while (i < 1.0) {
i += Time.deltaTime * rate;
thisTransform.position = Vector3.Lerp(startPos, endPos, i);
yield;
}
}
What part isn't working? Looks fine to me, but I'm not that good a picking faults in JS.
"What part isn't working? Looks fine to me, but I'm not that good a picking faults in JS."
I'm not sure, maybe I'm not using it correctly? I have it attached to the camera.
Answer by Berenger · Feb 27, 2012 at 04:11 AM
The function seems ok. But it need to be called at some point. Only some functions are called by Unity (Start, Awake, Update etc)
Your answer
![](https://koobas.hobune.stream/wayback/20220613064525im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Moving an object 0 Answers
How to get my character to move left to right? 0 Answers
How Can I Stop Rotation From This Script? 0 Answers
A node in a childnode? 1 Answer