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
1 registered members (TipmyPip), 18,388 guests, and 6 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
Making the camera follow an object? #323725
05/16/10 22:58
05/16/10 22:58
Joined: May 2010
Posts: 13
J
Jack2010 Offline OP
Newbie
Jack2010  Offline OP
Newbie
J

Joined: May 2010
Posts: 13
Hey guys! Is it possible to make the camera follow an object when it moves using the arrow keys (including tilt, pan, roll angles assigned to keys)? If so, how would I do it?

Thanks!

Last edited by Jack2010; 05/16/10 22:58.
Re: Making the camera follow an object? [Re: Jack2010] #323726
05/16/10 23:04
05/16/10 23:04
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
action object_with_camera() {
VECTOR o_speed;
while(1) {
my.pan += (key_a-key_d)*10*time_step;
o_speed.x = (key_w-key_s)*20*time_step;
o_speed.y = 0;
o_speed.z = -c_trace(my.x,vector(my.x,my.y,my.z-500),IGNORE_ME | IGNORE_PASSABLE);
c_move(me,o_speed,nullvector,GLIDE);

camera.x = my.x-300*cos(my.pan);
camera.y = my.y-300*sin(my.pan);
camera.z = my.z+150;
camera.pan = my.pan;
camera.tilt = -20;
wait(1);
}
}

Should work, untested.

EDIT: When reading your post a second time I'm not sure if I understood you correctly!?

BTW: Welcome to the gamestudio forums!

Last edited by Superku; 05/16/10 23:05.

"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Making the camera follow an object? [Re: Superku] #323749
05/17/10 07:11
05/17/10 07:11
Joined: May 2010
Posts: 13
J
Jack2010 Offline OP
Newbie
Jack2010  Offline OP
Newbie
J

Joined: May 2010
Posts: 13
Originally Posted By: Superku
action object_with_camera() {
VECTOR o_speed;
while(1) {
my.pan += (key_a-key_d)*10*time_step;
o_speed.x = (key_w-key_s)*20*time_step;
o_speed.y = 0;
o_speed.z = -c_trace(my.x,vector(my.x,my.y,my.z-500),IGNORE_ME | IGNORE_PASSABLE);
c_move(me,o_speed,nullvector,GLIDE);

camera.x = my.x-300*cos(my.pan);
camera.y = my.y-300*sin(my.pan);
camera.z = my.z+150;
camera.pan = my.pan;
camera.tilt = -20;
wait(1);
}
}

Should work, untested.

EDIT: When reading your post a second time I'm not sure if I understood you correctly!?

BTW: Welcome to the gamestudio forums!


Thanks! Basically, I need the camera to follow the object both when it moves and when it tilts/pans/rolls, kind of like in the wizard shooter in the tutorial (workshop24 I think) but not just the pan angle.

Seems a bit confusing, eh?

Thanks again!

Re: Making the camera follow an object? [Re: Jack2010] #323767
05/17/10 10:27
05/17/10 10:27
Joined: Apr 2010
Posts: 172
W
wdlmaster Offline
Member
wdlmaster  Offline
Member
W

Joined: Apr 2010
Posts: 172
Code:
vec_set (camera.pan,my.pan);
vec_set (camera.x,vector(-500,0,0));
vec_rotate (camera.x,camera.pan);
vec_add (camera.x,my.x);



the 2nd line gives the "offset" relative to the entity.

Re: Making the camera follow an object? [Re: wdlmaster] #324761
05/23/10 06:06
05/23/10 06:06
Joined: Apr 2010
Posts: 56
Badrizmo Offline
Junior Member
Badrizmo  Offline
Junior Member

Joined: Apr 2010
Posts: 56
@Jack: There was a tutorial that covers all sorts of cameras (first person, 3rd person, resident evil style cameras) I think you should take a look at it. Here is a link

http://www.opserver.de/coni_users/web_users/pirvu/au/tutorials/zipped/camtut.pdf


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