|
|
Movement Problem - Player hängt nach drehen in Wand fest
#394887
02/17/12 13:38
02/17/12 13:38
|
Joined: Dec 2011
Posts: 13
witzdestages
OP
Newbie
|
OP
Newbie
Joined: Dec 2011
Posts: 13
|
Hallo, ich hatte mir ein Player Code aus nem Aum kopiert und habe damit nur das Problem, das wenn ich ich mich in der nähe von Wänden drehe, das der Player soweit nach oben springt bis er von irgendwas gestoppt wird und dort fest hängt. Der Player kann sich zwar noch drehen und die lauf Animation geht auch noch, aber der Player kommt nicht mehr von der Stelle. Hier ein Bild davon wie der Player fest hängt: http://oneill.bplaced.net/shot_0.jpgWie kann man dieses Problem denn beheben ? Hatte vielleicht gedacht das man irgendwie den Abstand zu den Wänden irgendwie definieren könnte, habe aber dazu auch nichts gefunden. Gibt es irgendeine Möglichkeit das das festhängen zu verhindern ? Hier der Code:
action player_cam() // player / camera code
{
VECTOR temp;
VECTOR temp2;
var movement_speed = 10; // movement speed
var anim_percentage;
var cam_angle = 20; // set the initial camera angle here
var cam_dist = 100; // set the default zoom in factor here
var cam_height = 0; // set the default camera height here
player = my; // I'm the player
while (1)
{
if((!key_w) && (!key_s)) // the player isn't moving at all?
{
ent_animate(my, "stand", anim_percentage, ANM_CYCLE); // and play the "stand" animation
}
else // the player is moving?
{
ent_animate(my, "walk", anim_percentage, ANM_CYCLE); // and play the "walk" animation
}
// zoom in / out using the mouse wheel
cam_dist += 1.2 * mickey.z * time_step;
// limit the distance between the camera and the player to 20...500
cam_dist = clamp(cam_dist, 50, 500);
// set the height of the camera using the up / down cursor keys
cam_height += 3 * (key_cuu - key_cud) * time_step;
// limit the height of the camera to 50...300
cam_height = clamp(cam_height, 0, 100);
// rotate the player using the A / D keys
my.pan += 4 * (key_a - key_d) * time_step;
anim_percentage += 5 * time_step; // 5 = animation speed
camera.x = player.x - cam_dist * cos(cam_angle);
camera.y = player.y - cam_dist * sin(cam_angle);
cam_angle += 5 * (key_cur - key_cul) * time_step; // 5 gives the camera rotation speed
camera.z = player.z + cam_height;
vec_set(temp2.x, my.x);
vec_sub(temp2.x, camera.x);
vec_to_angle(camera.pan, temp2); // rotate the camera towards the player at all times
temp.z -= 10000;
temp.x = movement_speed * (key_w - key_s) * time_step;
temp.y = 0;
temp.z = -c_trace (my.x, temp.x, IGNORE_ME | IGNORE_PASSABLE | USE_BOX) - 0.01; // play with 2
c_move (my, temp.x, nullvector, IGNORE_PASSABLE | GLIDE);
wait (1);
}
}
Last edited by witzdestages; 02/17/12 13:39.
|
|
|
Re: Movement Problem - Player hängt nach drehen in Wand fest
[Re: Ch40zzC0d3r]
#394901
02/17/12 14:53
02/17/12 14:53
|
Joined: Dec 2011
Posts: 13
witzdestages
OP
Newbie
|
OP
Newbie
Joined: Dec 2011
Posts: 13
|
OK, habs jetzt raus. Einfach die Zeile
my.pan += 4 * (key_a - key_d) * time_step;
mit
c_rotate(me,vector(time_step * (key_a - key_d) * 5,0,0),GLIDE);
ersetzten. funktioniert nun wie es soll.
Last edited by witzdestages; 02/17/12 16:38.
|
|
|
Re: Movement Problem - Player hängt nach drehen in Wand fest
[Re: witzdestages]
#394919
02/17/12 19:01
02/17/12 19:01
|
Joined: Oct 2011
Posts: 1,082 Germany
Ch40zzC0d3r
Serious User
|
Serious User
Joined: Oct 2011
Posts: 1,082
Germany
|
Wie löst man mein problem? Normalerweise dieser Code:
me.pan = camera.pan;
Wie macht man das mit c_rotate?
Last edited by Ch40zzC0d3r; 02/17/12 19:01.
|
|
|
|