1 registered members (AndrewAMD),
684
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Speed limit
[Re: theDust]
#222007
08/17/08 14:30
08/17/08 14:30
|
Joined: Sep 2007
Posts: 761 Hrvatska (Croatia ), Slavonski...
cro_games
User
|
User
Joined: Sep 2007
Posts: 761
Hrvatska (Croatia ), Slavonski...
|
Try this: player_speed.x = minv(100,(maxv(player_speed.x, -100))) // player_speed.x will be limited between -100 and 100
player_speed.y = minv(100,(maxv(player_speed.y, -100))) // player_speed.y will be limited between -100 and 100
Last edited by cro_games; 08/17/08 14:38.
|
|
|
Re: Speed limit
[Re: cro_games]
#222012
08/17/08 15:13
08/17/08 15:13
|
Joined: Aug 2003
Posts: 7,439 Red Dwarf
Michael_Schwarz
Senior Expert
|
Senior Expert
Joined: Aug 2003
Posts: 7,439
Red Dwarf
|
player_speed.x = clamp(player_speed.x, -100, 100); player_speed.y = clamp(player_speed.y, -100, 100);
"Sometimes JCL reminds me of Notch, but more competent" ~ Kiyaku
|
|
|
Re: Speed limit
[Re: Michael_Schwarz]
#222042
08/17/08 18:37
08/17/08 18:37
|
Joined: Mar 2008
Posts: 104
theDust
OP
Member
|
OP
Member
Joined: Mar 2008
Posts: 104
|
This two codes are working but my player is moving a bit in the wrong direction now. Really weird...I'll try to fix this, any idea is welcome btw I move my player ( a ball) with this code: phent_addtorqueglobal (ball, player_speed);
|
|
|
Re: Speed limit
[Re: cro_games]
#222168
08/18/08 10:19
08/18/08 10:19
|
Joined: Mar 2008
Posts: 104
theDust
OP
Member
|
OP
Member
Joined: Mar 2008
Posts: 104
|
Here the action of my player:
action spieler() { zeiger = my; my.emask |= (ENABLE_BLOCK | ENABLE_ENTITY); phent_settype (zeiger, PH_RIGID, PH_SPHERE); phent_setmass (zeiger, 1,PH_SPHERE); phent_setfriction (zeiger, 500); phent_setdamping (zeiger, 10, 50); phent_setelasticity (zeiger, 50, 100);
while (1) { jump.x = 0; jump.y = 0; jump.z = 30000; my.event = jump2; winkel = cam_angle + 270; if(key_cur) cam_angle -= 3*time_step; if(key_cul) cam_angle += 3*time_step; if(key_cuu) { player_speed.x -= cos (winkel) * 3 *time_step; player_speed.y -= sin (winkel) * 3 *time_step; } if(key_cud) { player_speed.x += cos (winkel) * 3 *time_step; player_speed.y += sin (winkel) * 3 *time_step; } if(key_cud != 1 && key_cuu != 1) { player_speed.x = 0; player_speed.y = 0; } cam(); phent_addtorqueglobal (zeiger, player_speed); wait (1); } }
player_speed is a vector (i have written VECTOR player_speed; in my Code). As you can see i always have used phent_setdamping, that doesn't help.
Last edited by theDust; 08/18/08 10:21.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|