Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 18,435 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Script for moving camera #113705
02/24/07 13:12
02/24/07 13:12
Joined: Nov 2006
Posts: 50
Brasil
Maloke Offline OP
Junior Member
Maloke  Offline OP
Junior Member

Joined: Nov 2006
Posts: 50
Brasil
This is my first contribution to the forum, hope this is usefull for someone!

I have created a script that moves your camera from where it is, to another position, and changes the direction in a smooth way. I have created an example to show and explain better.
You klick on a model, and the desired final position for the camera is the position of a vertex on the cliked model. Also, the funtion uses another position of the model´s vertex to indicate where the camera should look at.

Get the example and you will understand exactly how it works.
Just clik on the boxes to make the camera move.
Hold right mouse button to look in another direction, and clik on the boxes. I think the camera movement is very cool !!

Get it here: Camera Script

This can be used to make cinematics too...and you can ajust the movement´s speed acording to your needs.

You can use it for free!
If there is any doubts about how it works, just ask me.
Hope its useful!!

Re: Script for moving camera [Re: Maloke] #113706
02/24/07 13:44
02/24/07 13:44
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline
Expert
Germanunkol  Offline
Expert

Joined: Jun 2006
Posts: 2,640
Earth
Hey, nice!
I like it!
Kinda fast, but, as you said, it's not that hard to change. Took me a bit of time to figure out how to, but I got it.

I like how you figure out in which direction to rotate. very cool. I do the same thing for one of my projects, although way more complicated. Thanks for this, very useful, i think i'll put that into my project!


~"I never let school interfere with my education"~
-Mark Twain
Re: Script for moving camera [Re: Maloke] #113707
02/24/07 14:19
02/24/07 14:19
Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
frazzle Offline
Expert
frazzle  Offline
Expert

Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
This is ineed a nice script to move the camera to a sertain spot, angled to a specified vertex, nice work Maloke

Cheers

Frazzle


Antec® Case
Intel® X58 Chipset
Intel® i7 975 Quad Core
8 GB RAM DDR3
SSD OCZ®-VERTEX2 3.5 x4 ; HD 600 GB
NVIDIA® GeForce GTX 295 Memory 1795GB
Re: Script for moving camera [Re: Germanunkol] #113708
02/24/07 16:22
02/24/07 16:22
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Very useful script!

Quote:

Kinda fast, but, as you said, it's not that hard to change. Took me a bit of time to figure out how to, but I got it.




I would like to have it really slow. I figured out how to slow down the turn, but not how to slow down the move forward!

An explanation how to change the speeds are welcomed, too!

Re: Script for moving camera [Re: Pappenheimer] #113709
02/24/07 19:44
02/24/07 19:44
Joined: Nov 2006
Posts: 50
Brasil
Maloke Offline OP
Junior Member
Maloke  Offline OP
Junior Member

Joined: Nov 2006
Posts: 50
Brasil
Thanks everybody!

I will try to help how to slow down...
On the original script, the camera dont travel at a constant speed. I create the vector of difference between the final position and the actual position, and then scale this vector about the factor "t" , witch starts from 1 , and each frame it gets smaller by t-=0.002; , so the speed gets faster each frame...

You can change to t-=0.001; , but still is a little faster.
If you remove this line, the movements speed will be constant, but dont forget to declare t to be smaller than 1, otherwise the scale command will maitain the same distance, and the camera wont move.

So, if you want the camera to move really slow, what you can do is to remove the t-=0.002; , and when the t variable is declared as var t=1; just change it to var t=0.999; this will move really slow. The smaller the t variable, faster the movement.

Just to make sure, here is the original code:
Code:

function move_camera(){
proc_kill(4);
beep();
var a;var b;var c;var d;var t=1;

vec_for_vertex(a,my,9); // Posição final da camera,Point for camera to stay. Can use a Skill.
vec_for_vertex(b,my,10); // Posição p/ camera olhar,Point to look at. Can use a Skill too.

while(1){

///////////////////////////////////////////////////////// Gira a Camera, Turn camera.
vec_diff(d.x,b.x,camera.x);vec_to_angle(d.pan,d.x);
d.pan=ang(d.pan-camera.pan);d.tilt=ang(d.tilt-camera.tilt);
d.pan*=0.05;d.tilt*=0.05;
camera.pan+=d.pan;camera.tilt+=d.tilt;
if(camera.roll!=0){camera.roll-=sign(camera.roll)*time;}

///////////////////////////////////////////////////////// Translada a Camera, Translade camera.
vec_diff(c.x,camera.x,a.x);vec_scale(c,t);t-=0.002;
vec_add(c.x,a);if(t>0.002){vec_set(camera.x,c.x);}else{vec_set(camera.x,a.x);}

///////////////////////////////////////////////////////// Para o movimento.Break the movement.
if(mouse_right){break;}
wait(1);}
}




And this the one wich moves really slow:
Code:

function move_camera(){
proc_kill(4);
beep();
var a;var b;var c;var d;var t=0.999;

vec_for_vertex(a,my,9); // Posição final da camera,Point for camera to stay. Can use a Skill.
vec_for_vertex(b,my,10); // Posição p/ camera olhar,Point to look at. Can use a Skill too.

while(1){

///////////////////////////////////////////////////////// Gira a Camera, Turn camera.
vec_diff(d.x,b.x,camera.x);vec_to_angle(d.pan,d.x);
d.pan=ang(d.pan-camera.pan);d.tilt=ang(d.tilt-camera.tilt);
d.pan*=0.05;d.tilt*=0.05;
camera.pan+=d.pan;camera.tilt+=d.tilt;
if(camera.roll!=0){camera.roll-=sign(camera.roll)*time;}

///////////////////////////////////////////////////////// Translada a Camera, Translade camera.
vec_diff(c.x,camera.x,a.x);vec_scale(c,t);//t-=0.001;
vec_add(c.x,a);if(t>0.002){vec_set(camera.x,c.x);}else{vec_set(camera.x,a.x);}

///////////////////////////////////////////////////////// Para o movimento.Break the movement.
if(mouse_right){break;}
wait(1);}
}



Last edited by Maloke; 02/24/07 19:50.

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1