x


Interpolating the motion of a camera moving from one node to another

I have written a script that moves the camera from one node to another when the player moves into a trigger. It also rotates the camera based on the rotation of the node. However, the camera doesn't actually "move", rather it teleports to the node.

I was trying to see if anyone could help me with making the camera move gradually from position A to the the position of the node and also interpolate the rotation while moving.

Here is the code I have written: (This script is attached to the trigger itself)

var camera1 : Camera; 


var node : Transform;
var Interpolation = 2;

function OnTriggerEnter (hit : Collider) 
{

    //camera1.enabled = false; 
    //camera2.enabled = true; 
    Debug.Log("Camera movement!");
    camera1.transform.rotation = (node.transform.rotation);
    camera1.transform.position = (node.transform.position);
}
more ▼

asked Nov 12 '10 at 08:10 AM

SirVictory gravatar image

SirVictory
1.7k 64 77 104

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

I haven't tried this before, since I've never needed to, but using the Vector3.Lerp() method should do what you need.

So try something like this:

camera1.transform = Vector3.Lerp(initialPosition, endingPosition, time)

Take a look at this link

more ▼

answered Nov 12 '10 at 02:36 PM

alee gravatar image

alee
16 2

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3003
x2166
x1368
x885
x35

asked: Nov 12 '10 at 08:10 AM

Seen: 1762 times

Last Updated: Nov 12 '10 at 08:10 AM