|
|
Re: 3rd person camera . Newbie help
[Re: foxdrop]
#190446
03/27/08 09:08
03/27/08 09:08
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
Expert
|
Expert
Joined: Jun 2006
Posts: 2,640
Earth
|
Code:
//add the vars to the very beginning of your main script:
var cam_distance = 100; var cam_height = 20; var cam_mode; define mode_3rd,0; define mode_first,1;
//add this function somewhere down the bottom (just before or after the main //method, for example:
function switch_cam_modes() { if(cam_mode == mode_3rd) { cam_mode = mode_first; } else { cam_mode = mode_3rd; } }
on_c = switch_cam_mode;
//then replace the code you posted with the following: } if(cam_mode == mode_first) { // camera updates 1st person view vec_set (Camera.x,player.x); camera.z += 27; camera.pan = player.pan; camera.tilt += (key_pgup - key_pgdn)*4*time; } else { //place cam behind player: vec_set(temp,vector(-cam_distance,cam_heigth,0)); vec_rotate(temp,camera.pan); vec_add(temp,player.x); vec_set(camera.x,temp); //make camera face player: vec_diff(temp,player.x,camera.x); vec_to_angle(camera.pan,temp); } wait(1); }
that's all... just tell me if it works or not, or if you need help with where to place the code... done... 
~"I never let school interfere with my education"~ -Mark Twain
|
|
|
Re: 3rd person camera . Newbie help
[Re: Germanunkol]
#190447
03/27/08 22:16
03/27/08 22:16
|
Joined: Mar 2008
Posts: 5
foxdrop
OP
Newbie
|
OP
Newbie
Joined: Mar 2008
Posts: 5
|
Thanks for your help but it dosn't seem to work, it comes up with: syntax error - nonexistent/empty function switch_cam_mode. Any clues? here's what i've got now:
// stcc.wdl
var video_mode = 7; var video_depth = 16; var move_vec[3] = 0,0,0; var idle_percent = 0; Var walk_percent = 0; var cam_distance = 100; var cam_height = 20; var cam_mode; define mode_3rd,0; define mode_first,1; function main() { level_load ("stcc.wmb"); wait(2); } function switch_cam_modes() { if(cam_mode == mode_3rd) { cam_mode = mode_first; } else { cam_mode = mode_3rd; } }
on_c = switch_cam_mode;
action player_move { player = me; wait(1); while (me != NULL) { move_vec[0] = (key_cuu - key_cud)*3 *time; move_vec[1] = (key_comma - key_period) *2 *time; player.pan += (key_cul-key_cur)*4 *time; ent_move(move_vec,NULLVECTOR); If (move_vec[0] == 0 && move_vec[1] == 0) { idle_percent = (idle_percent +5*time)%100; ent_animate(me,"idle",idle_percent,ANM_CYCLE); } else { // our movement animations will go here walk_percent = (walk_percent + sign(move_vec[0])*5*time)%100; ent_animate(player,"walk",walk_percent,ANM_CYCLE); } wait(1); } if(cam_mode == mode_first) { // camera updates 1st person view vec_set (Camera.x,player.x); camera.z += 27; camera.pan = player.pan; camera.tilt += (key_pgup - key_pgdn)*4*time; } else { //place cam behind player: vec_set(temp,vector(-cam_distance,cam_height,0)); vec_rotate(temp,camera.pan); vec_add(temp,player.x); vec_set(camera.x,temp); //make camera face player: vec_diff(temp,player.x,camera.x); vec_to_angle(camera.pan,temp); } wait(1); }
|
|
|
Re: 3rd person camera . Newbie help
[Re: foxdrop]
#190448
03/27/08 22:23
03/27/08 22:23
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
Expert
|
Expert
Joined: Jun 2006
Posts: 2,640
Earth
|
yeah. my bad... a typo... replace the line: on_c = switch_cam_mode; with: on_c = switch_cam_modes; (just add an s at the end...) also, you need to move the camera code, try replacing the action player_move with this: Code:
action player_move { player = me; wait(1); while (me != NULL) { move_vec[0] = (key_cuu - key_cud)*3 *time; move_vec[1] = (key_comma - key_period) *2 *time; player.pan += (key_cul-key_cur)*4 *time; ent_move(move_vec,NULLVECTOR); If (move_vec[0] == 0 && move_vec[1] == 0) { idle_percent = (idle_percent +5*time)%100; ent_animate(me,"idle",idle_percent,ANM_CYCLE); } else { // our movement animations will go here walk_percent = (walk_percent + sign(move_vec[0])*5*time)%100; ent_animate(player,"walk",walk_percent,ANM_CYCLE); } if(cam_mode == mode_first) { // camera updates 1st person view vec_set (Camera.x,player.x); camera.z += 27; camera.pan = player.pan; camera.tilt += (key_pgup - key_pgdn)*4*time; } else { //place cam behind player: vec_set(temp,vector(-cam_distance,cam_height,0)); vec_rotate(temp,camera.pan); vec_add(temp,player.x); vec_set(camera.x,temp); //make camera face player: vec_diff(temp,player.x,camera.x); vec_to_angle(camera.pan,temp); } wait(1);
}
}
hope it works...
~"I never let school interfere with my education"~ -Mark Twain
|
|
|
Re: 3rd person camera . Newbie help
[Re: foxdrop]
#190450
03/28/08 01:12
03/28/08 01:12
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
Expert
|
Expert
Joined: Jun 2006
Posts: 2,640
Earth
|
i'm sorry this is causing so much problems... yeah, replace, in the action move_player: vec_rotate(temp,camera.pan); with vec_rotate(temp,player.pan); and then it should work... my bad again... just sloppy work  Micha
~"I never let school interfere with my education"~ -Mark Twain
|
|
|
Re: 3rd person camera . Newbie help
[Re: foxdrop]
#199872
04/01/08 15:37
04/01/08 15:37
|
Joined: Oct 2007
Posts: 116
sydan
Member
|
Member
Joined: Oct 2007
Posts: 116
|
I use a camera attached to a vertex point that floats behind the player. For a smooth action make the camera MOVE towards the vertex, dont make it JUMP to the vertex. If you place the camera in a solid object this also allows collision detection for the camera. Not a hugely useful comment but thats the best I can do for now.
For some reason, my ambition always seems to beat my ability.
|
|
|
|