0 registered members (),
18,767
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Making the camera follow an object?
#323725
05/16/10 22:58
05/16/10 22:58
|
Joined: May 2010
Posts: 13
Jack2010
OP
Newbie
|
OP
Newbie
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
Senior Expert
|
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
Jack2010
OP
Newbie
|
OP
Newbie
Joined: May 2010
Posts: 13
|
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!
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|