Notifications
Clear all

[Closed] Orbit camera around target

Hi!

           I'm having trouble writing a script that can make a target camera orbit it's target at a set distance and add keyframes at every 10degree increment.
           
           Here is the process the script should create:

[ol]
[li]Place camera above target at around 600mm away[/li][li]rotate camera through 360 degrees and add a keyframe at every 10 degree increment[/li][li]drop camera by 10 degrees and repeat step 2 till camera is at very bottom of target[/li][/ol]

Here is the code I have so far, it just doesn’t seem to work as expected.

[ol]
[li]When the camera is at the top it sits there stationary for 36 frames.[/li][/ol]


               cam = TargetCamera target:(targetObject pos:[0,0,0]) pos:[0,0,600];
               
               fn rotateCamera hAngle vAngle = (
               	hAngle = (90 - hAngle);
               	
               	x = cam.Target.pos[1] + (cos(hAngle) * sin(vAngle) * cam.targetDistance);
               	y = cam.Target.pos[2] + (sin(hAngle) * sin(vAngle) * cam.targetDistance);
               	z = cam.Target.pos[3] + (cos(vAngle) * cam.targetDistance);
               	
               	return [x,y,z];
               )
               
               count = 0;
               	
               for v = 0 to 180 by 10 do (
               	
               	for h = 0 to 350 by 10 do (
               		
               		at time count animate on cam.pos = rotateCamera (350 - h) v;
               		count = count + 1;
               		
               	)
               	
               )
               
           Could anybody tell me where I am going wrong? Or point me in the direction of an easier way of doing this?
           
           Thanks in advance!
2 Replies

Look up the ‘about’ context in the help file. That let’s you specify rotations, or whatever, ‘about’ another object or position.

Thanks for your reply. I had a play with “about” before, although I got the camera to rotate around the target exactly how I wanted it, the top of the camera doesn’t always point “north”.

Sorry if that doesn’t make much sense.