Posted By: Vyshess
PhysX movement - 11/16/11 22:24
Hi @ all!
I started my next game and want to use the physic-engine.
everything works good except the player movement.
at first I was giving the player a box collision but that doesn`t works because, by running the skript, the player disappears suddenly or falls through the test-level(a hollow block),not sure what exactly happens.
So I was trying the capsule collision.at first it looks good.I see the player and can walk around..but there is something strange. I set the foots of the player exactly on the ground but if I push one of the movement-keys, the player model is suddenly a bit over the ground. apart from that the movement works very good.
thx for help
my player-code:
I started my next game and want to use the physic-engine.
everything works good except the player movement.
at first I was giving the player a box collision but that doesn`t works because, by running the skript, the player disappears suddenly or falls through the test-level(a hollow block),not sure what exactly happens.
So I was trying the capsule collision.at first it looks good.I see the player and can walk around..but there is something strange. I set the foots of the player exactly on the ground but if I push one of the movement-keys, the player model is suddenly a bit over the ground. apart from that the movement works very good.
thx for help
my player-code:
Code:
action hero() { var anim_percentage; pXent_settype(my, PH_CHAR, PH_CAPSULE); set(my,SHADOW); wait(1); my.emask |= ENABLE_SCAN; // make the player sensitive to scanning player = my; // I'm the player while(players_health > 0) { //player movement// movement_speed.x = 10 * (key_cuu - key_cud) * time_step; // move the player using "cuu" and "cud" movement_speed.y = 10 * (key_cul - key_cur) * time_step; // move the player using "cur" and "cul" pXent_movechar(me, movement_speed, NULL, 0); /////////////////// //player animation// if(key_cuu || key_cud) { if(movement_speed.x > 0){my.pan = 0;} // turn player to right if(movement_speed.x < 0){my.pan = 180;} // turn player to left anim_percentage += 7 * time_step; ent_animate(my, "walk", anim_percentage, ANM_CYCLE); // play the "walk" animation } if(key_cur || key_cul) { if(movement_speed.y > 0){my.pan = 90;} // turn player to right if(movement_speed.y < 0){my.pan = -90;} // turn player to left anim_percentage += 7 * time_step; ent_animate(my, "walk", anim_percentage, ANM_CYCLE); // play the "walk" animation } if (key_cuu + key_cud + key_cur + key_cul == 0) // none of the movement keys are pressed? { anim_percentage += 1.2 * time_step; ent_animate(my, "idle", anim_percentage, ANM_CYCLE); // play the "stand" animation } ///////////////////// on_l = plant_bomb; wait(1); } }