|
7 registered members (3run, miwok, AndrewAMD, Quad, TipmyPip, fairtrader, 1 invisible),
637
guests, and 2
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
3rd person camera view
#261785
04/20/09 07:27
04/20/09 07:27
|
Joined: Mar 2009
Posts: 276 Cebu City, Philippines
boyax
OP
Member
|
OP
Member
Joined: Mar 2009
Posts: 276
Cebu City, Philippines
|
Hi, i'm just wondering... i've browse some codes for 3rd person camera view in which the camera is just on top of the player whenever it moves... To compute for the camera xyz positions, i see this code like:
camera.x = player.x - 15 * cos(player.pan);
camera.y = player.y - 15 * sin(player.pan);
camera.z = player.z + 4;
Is it necessary to multiply player.x to cos(angle) ??? I'm thinking, you could get the camera.x by this formula:
camera.x = player.x - distance_cam_player; //distance_cam_player -> distance bet cam & player
Any advise? Thanks
|
|
|
Re: 3rd person camera view
[Re: Rasch]
#261790
04/20/09 07:52
04/20/09 07:52
|
Joined: Oct 2007
Posts: 5,209 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,209
İstanbul, Turkey
|
camera.x = player.x - 15 * cos(player.pan+cam_pan_modifier); camera.y = player.y - 15 * sin(player.pan+cam_pan_modifier); camera.z = player.z + 4;
and in your player loop:
cam_pan_modifier +=mouse_force.y*times_tep*10;//10 is mouse speed.
3333333333
|
|
|
Re: 3rd person camera view
[Re: boyax]
#261796
04/20/09 09:36
04/20/09 09:36
|
Joined: Mar 2009
Posts: 276 Cebu City, Philippines
boyax
OP
Member
|
OP
Member
Joined: Mar 2009
Posts: 276
Cebu City, Philippines
|
I'm not making it work..supposed to be I (the camera) must sit on top of the player... I just making a simple moving of the player..
var distance_cam_player = 85; //distance bet. cam & player
///////////////////////////////////////////////////
action move_cat()
{
player = my;
while(1)
{
handle_movement();
handle_camera();
wait(1);
}
}
function handle_movement()
{
if(1 == key_w)
{
my.x += 5 * time_step;
}
else if(1 == key_s)
{
my.x -= 5 * time_step;
}
else if(1 == key_a)
{
my.pan += 5 * time_step;
}
else if(1 == key_d)
{
my.pan -= 5 * time_step;
}
wait(1);
}
function handle_camera()
{
while (player == NULL) { wait (0); }
camera.x = player.x - distance_cam_player * cos(player.pan);
camera.y = player.y - distance_cam_player * sin(player.pan);
camera.z = player.z + 24; //30-6=24 -> z of the camera
camera.pan = player.pan;
}
but my output goes to be: So, its kinda a wrong computation of the camera pan? Everytime I press W or S, it moves sideways instead moving forward.. but my orientation at the start, the character is facing on its x-axis.. the camera computation have change it.. Any idea? Thanks
|
|
|
Re: 3rd person camera view
[Re: Jaxas]
#261797
04/20/09 09:37
04/20/09 09:37
|
Joined: Oct 2007
Posts: 5,209 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,209
İstanbul, Turkey
|
define it 
action player_act(){
var cam_pan_modifier = 0;
var mouse_speed = 10;
player =me;
........//your own needed code here
while(1){
camera.x = player.x - 15 * cos(player.pan+cam_pan_modifier);
camera.y = player.y - 15 * sin(player.pan+cam_pan_modifier);
camera.z = player.z + 4;
cam_pan_modifier +=mouse_force.y*times_tep*mouse_speed;
.....//movement etc code
wait(1);
}
}
edit: i was poting this before you posted.
Last edited by Quadraxas; 04/20/09 09:39.
3333333333
|
|
|
|