|
0 registered members (),
635
guests, and 2
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Problem with the physics engine (player acceleration)
#221109
08/12/08 12:30
08/12/08 12:30
|
Joined: Aug 2008
Posts: 4
DDFD
OP
Guest
|
OP
Guest
Joined: Aug 2008
Posts: 4
|
Hello,
I dont have much experience with 3DGS, yet, but I wanted to make physics into my little game. But when the physics are activated and I press the key to move the player and then release the key, the acceleration of the player is too high. So the player slids a bit (like on ice) and then stops. How can I put off the acceleration of the player or make, that the player stops, when I release the key, but keep the physics of the player? Please help me. P.S. Sorry for my bad english. I'm german.
Hallo,
Ich hab noch nicht so viel Erfahrung mit 3DGS, aber ich wollte Physik in mein kleines Spiel bringen. Das Problem ist aber, wenn die Physik aktiviert ist und ich die Taste drücke um mit dem Player zu laufen und dann die Taste loslasse, ist die Beschleunigung vom Player so hoch, dass der Player noch ein kleines bisschen auf dem Boden rutscht (wie auf Eis), bis er stoppt. Wie kann ich also die Beschleunigung des Players abschalten oder es schaffen, dass der Player sofort stoppt, wenn ich die Taste loslasse, ohne die Physik des Players abzuschalten? Bitte helft mir.
|
|
|
Re: Problem with the physics engine (player acceleration)
[Re: zwecklos]
#221557
08/14/08 18:20
08/14/08 18:20
|
Joined: Aug 2008
Posts: 4
DDFD
OP
Guest
|
OP
Guest
Joined: Aug 2008
Posts: 4
|
Hallo, Hier ist der Teil des Skriptes: action player_main() { player = me; set(my, SHADOW); phent_settype(me, PH_RIGID, PH_BOX); phent_setmass(me, 80, PH_BOX); phent_setelasticity (me, 0, 100); phent_setdamping (me, 0, 0); phent_setfriction(me, 50); phent_setgroup(me, 1); while(1) { phent_addforcelocal(my, vector((key_w * (key_shift + 1) - key_s)*400000*time_step, (key_a - key_d)*400000*time_step, 0), nullvector); phent_addcentralforce(my, vector(0, 0, key_space*400000*time_step)); ent_animate(me, "walk", my.skill21 ,ANM_CYCLE); my.skill21 += 100 * time_step / 28; if (key_w == 0 && key_a == 0 && key_s == 0 && key_d == 0 && key_cuu == 0 && key_cud == 0 && key_cul == 0 && key_cur == 0) { my.skill21 = 0; ent_animate(me, "stand", my.skill22, ANM_CYCLE); my.skill22 += 3 * time_step; } update_views(); wait(1); } }
Sobald ich friction höher stelle kippt das Modell leichter um. Gibt es vielleicht einen Ersatz für "phent_addforcelocal", bei der das Modell nicht weiterrutscht nach dem Loslassen der Taste? Oder kann man das irgendwie abstellen?
Danke für die Hilfe.
|
|
|
Re: Problem with the physics engine (player acceleration)
[Re: DDFD]
#221691
08/15/08 14:51
08/15/08 14:51
|
Joined: Sep 2005
Posts: 274 Switzerland - Zurich
zwecklos
Member
|
Member
Joined: Sep 2005
Posts: 274
Switzerland - Zurich
|
Hallo, Was passiert wenn du zbsp. phent_setdamping(spieler,100, 100); definierst? Ist dann das langsame Herunterfallen das einzige Problem?
Versuch mal friction auf 0 zu setzten und damping auf 100.
phent_setfriction(spieler, 0.0); phent_setdamping(spieler, 100.0, 100.0);
Du kannst via c_trace feststellen, ob dein Spieler sich in der Luft befindet, wenn ja, kannst du mit phent_addcentralforce(my, vector(0, 0, -5000); die Fallgeschwindigkeit erhöhen um dem entgegen zu wirken.
cheers
|
|
|
Re: Problem with the physics engine (player acceleration)
[Re: zwecklos]
#221886
08/16/08 21:35
08/16/08 21:35
|
Joined: Aug 2008
Posts: 4
DDFD
OP
Guest
|
OP
Guest
Joined: Aug 2008
Posts: 4
|
Hallo, Vielen Dank. Das mit c_trace war eine gute Idee. Hier die (hoffentlich gute) Umsetzung
action player_main() { player = me; set(my, SHADOW); phent_settype(me, PH_RIGID, PH_BOX); phent_setmass(me, 80, PH_BOX); phent_setelasticity (me, 0, 100); phent_setdamping (me, 100, 100); phent_setfriction(me, 0); phent_setgroup(me, 1); while(1) { jump = key_space; if(c_trace(vector(my.x, my.y, my.z - 16), vector(my.x, my.y, my.z - 40000), USE_BOX|IGNORE_PASSABLE|IGNORE_ME) > 0) { phent_addforcelocal(my, vector((key_w * (key_shift + 1) - key_s)*400000*time_step, (key_a - key_d)*400000*time_step, -200000), nullvector); ent_animate(me, "walk", my.skill21 ,ANM_CYCLE); //Walk-Animation my.skill21 += 100 * time_step / 28; if (key_w == 0 && key_a == 0 && key_s == 0 && key_d == 0 && key_cuu == 0 && key_cud == 0 && key_cul == 0 && key_cur == 0) { my.skill21 = 0; ent_animate(me, "stand", my.skill22, ANM_CYCLE); //Steh-Animation my.skill22 += 3 * time_step; } update_views(); } else { do { phent_addforcelocal(my, vector((key_w * (key_shift + 1) - key_s)*400000*time_step, (key_a - key_d)*400000*time_step, jump*800000*time_step), nullvector); ent_animate(me, "walk", my.skill21 ,ANM_CYCLE); //Walk-Animation my.skill21 += 100 * time_step / 28; if (key_w == 0 && key_a == 0 && key_s == 0 && key_d == 0 && key_cuu == 0 && key_cud == 0 && key_cul == 0 && key_cur == 0) { my.skill21 = 0; ent_animate(me, "stand", my.skill22, ANM_CYCLE); //Steh-Animation my.skill22 += 3 * time_step; } update_views(); wait(1); } while(jump && c_trace(vector(my.x, my.y, my.z - 16), vector(my.x, my.y, my.z - 40000), USE_BOX|IGNORE_PASSABLE|IGNORE_ME) <= 50); } update_views(); wait(1); } }
Bis zum nächsten Problem. ;-)
|
|
|
|