Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
3 registered members (TedMar, AndrewAMD, fairtrader), 578 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
3rd person camera . Newbie help #190445
03/27/08 00:22
03/27/08 00:22
Joined: Mar 2008
Posts: 5
F
foxdrop Offline OP
Newbie
foxdrop  Offline OP
Newbie
F

Joined: Mar 2008
Posts: 5
How do i add a 3rd person camera view into my game? i've already got a the 1st person view but i want to add the 3rd person view aswell.

Here's what i've got so far what do i need to add for the following:

}
// 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;
wait(1);
}

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 Offline
Expert
Germanunkol  Offline
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
F
foxdrop Offline OP
Newbie
foxdrop  Offline OP
Newbie
F

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 Offline
Expert
Germanunkol  Offline
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: Germanunkol] #190449
03/27/08 23:47
03/27/08 23:47
Joined: Mar 2008
Posts: 5
F
foxdrop Offline OP
Newbie
foxdrop  Offline OP
Newbie
F

Joined: Mar 2008
Posts: 5
I got no errors, however when i run the game, everything in the game all spins around really fast, and i can't stop it unless i press c, which puts it in 1st person mode. any idea's?

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 Offline
Expert
Germanunkol  Offline
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: Germanunkol] #190451
03/28/08 09:55
03/28/08 09:55
Joined: Mar 2008
Posts: 5
F
foxdrop Offline OP
Newbie
foxdrop  Offline OP
Newbie
F

Joined: Mar 2008
Posts: 5
Yay. Thanks for your help Germanunkol, now everything works properly

Re: 3rd person camera . Newbie help [Re: foxdrop] #199872
04/01/08 15:37
04/01/08 15:37
Joined: Oct 2007
Posts: 116
S
sydan Offline
Member
sydan  Offline
Member
S

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.

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | 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