Posted By: 3run
CHAR movement - 02/23/11 13:06
I'm trying to make basic movement with PhysX, here is the example:
And here is the demo:
Download link
It works, but sometimes pushed crates, change they angle (PAN) after they stopped moving, what is wrong in my script?
Code:
////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////// #include <acknex.h> #include <default.c> #include <ackphysX.h> ////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////// function main() { fps_max = 60; physX_open(); video_set(800,600,32,0); level_load("1.wmb"); wait(3); sun_light = 0; pX_setgravity(vector(0,0,-10)); sky_color.red = 1; sky_color.green = 1; sky_color.blue = 1; } ////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////// #define absdist_x skill1 #define absdist_y skill2 #define absdist_z skill3 ////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////// action hero() { player = my; pXent_settype(my,PH_CHAR,PH_CONVEX); pXent_setskinwidth(my,0); while(1) { my.absdist_x = 10 * (key_w - key_s) * time_step; my.absdist_y = 10 * (key_a - key_d) * time_step; result = c_trace(my.x,vector(my.x,my.y,my.z-1000),IGNORE_ME|USE_BOX); if(result > 10){my.absdist_z -= 0.1 * time_step;} else{my.absdist_z = 0;} vec_rotate(my.absdist_x,my.pan); my.pan -= 0.5 * mickey.x * time_step; pXent_movechar(my,my.absdist_x,my.pan,0); vec_set(camera.x,vector(my.x,my.y,my.z + 1200)); camera.pan += ang(my.pan - camera.pan) * time_step * 0.8; camera.tilt = -90; wait(1); } } ////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////// action pX_boX() { pXent_settype(my,PH_RIGID,PH_BOX); pXent_setfriction(my,100); pXent_setskinwidth(my,0); } ////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
Download link
It works, but sometimes pushed crates, change they angle (PAN) after they stopped moving, what is wrong in my script?