3 registered members (AndrewAMD, VoroneTZ, 1 invisible),
1,578
guests, and 7
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: 3d
[Re: Funeral]
#406921
09/02/12 01:25
09/02/12 01:25
|
Joined: Jul 2008
Posts: 2,107 Germany
rayp
X
|
X
Joined: Jul 2008
Posts: 2,107
Germany
|
if you not turn the pan into direction u wanna walk into u need to use absolute vectors not relative. But i think u have a logic error. in a 3rd person platformer you normally turn the player then setting camera angles to player angles. or do it like that way
VECTOR dist;
if(key_w) dist.x = 2;
if(key_s) dist.x = -2;
c_move(me, vector(dist.x*time_step,.......
To "feed" c_move with absoulte use the second vector in c_move instruction. greets
Acknex umgibt uns...zwischen Dir, mir, dem Stein dort... "Hey Griswold ... where u gonna put a tree that big ?" 1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected rayp.flags |= UNTOUCHABLE;
|
|
|
Re: 3d
[Re: Kartoffel]
#406951
09/03/12 02:01
09/03/12 02:01
|
Joined: Dec 2008
Posts: 83 Buenos Aires, Argentina
Funeral
OP
Junior Member
|
OP
Junior Member
Joined: Dec 2008
Posts: 83
Buenos Aires, Argentina
|
this the movement and camera code, how do i add this intruction you gave me? i tried putting temp in the movement_vector place but it didnt work. code:
var distance, angle; VECTOR temp; distance = 400; angle =0; while(me) { if(player) { camera.x = player.x-distance*cos(angle); camera.y = player.y-distance*sin(angle); camera.z = player.z+100;
vec_set(temp,player.x); vec_sub(temp,camera.x); vec_to_angle(camera.pan,temp); vec_set(camera.tilt,player-300); } c_move(me,nullvector,vector(joy_force.x * 7 * time_step, joy_force.y * 7 * time_step, 0 ), GLIDE);
|
|
|
Re: 3d
[Re: Funeral]
#406966
09/03/12 12:41
09/03/12 12:41
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
to post some code use [ code] at the beginning and [ /code] at the end and it'll look like this: (much easier to read)
var distance, angle;
VECTOR temp;
distance = 400;
angle =0;
VECTOR move_vec; // NEW | the movement vector
while(me)
{
if(player)
{
camera.x = player.x-distance*cos(angle);
camera.y = player.y-distance*sin(angle);
camera.z = player.z+100;
vec_set(temp,player.x);
vec_sub(temp,camera.x);
vec_to_angle(camera.pan,temp);
vec_set(camera.tilt,player-300);
}
vec_set(move_vec, vector(joy_force.x * 7 * time_step, joy_force.y * 7 * time_step, 0)); // NEW
vec_rotate(move_vec, vector(camera.pan, 0, 0)); // NEW
c_move(me, nullvector, move_vec, GLIDE); // CHANGED
}
I marked new lines with // NEW at the end and changed lines with // CHANGEDIt's actually really simple: you moved your player with this: c_move(me, nullvector, vector(joy_force.x * 7 * time_step, joy_force.y * 7 * time_step, 0), GLIDE); I just created a new vector called move_vec, which is set to your previous movement vector (the blue one above) every frame by doing this: vec_set(move_vec, vector(joy_force.x * 7 * time_step, joy_force.y * 7 * time_step, 0)); After this I rotate this vector with the camera's pan-angle: vec_rotate( move_vec, vector(camera.pan, 0, 0)); And then move the player: c_move(me, nullvector, move_vec, GLIDE);
Last edited by Kartoffel; 09/03/12 12:46.
POTATO-MAN saves the day! - Random
|
|
|
|