Posted By: CodeMaster
code crash after level_load - 10/25/15 13:42
hi all
i'm not expert for physics and i have a few questions how to use physx in my game, of course on the proper way
everything works pretty well until the moment when i need to load second level and then return in the first
i get crash e1513 script crash in physX_open
i tried to clean up the pointers with ent_remove but is still something wrong
in this code when i change level over five times script crash (when i put this code in my game i get crash fist time when i back in level where is physic object)
can someone show me where i wrong and explain what happens to physic objects after level load?
i'm not expert for physics and i have a few questions how to use physx in my game, of course on the proper way
everything works pretty well until the moment when i need to load second level and then return in the first
i get crash e1513 script crash in physX_open
i tried to clean up the pointers with ent_remove but is still something wrong
in this code when i change level over five times script crash (when i put this code in my game i get crash fist time when i back in level where is physic object)
Code:
#include <default.c> #include <ackphysX.h> #include <mtlFX.c> ENTITY *pole; action flag(){ my.material = mtl_twosided_alpha; // attach flag to pole c_setminmax(pole); c_setminmax(my); vec_set(my.x,vector(pole.x, pole.y+(my.max_y-my.min_y)/2, pole.z+pole.max_z-(my.max_z-my.min_z)/2)); // setup flag cloth var cloth_options[40]; memcpy(cloth_options,CLOTH_DEFAULT,40*sizeof(var)); vec_set(cloth_options[25],vector(-10,20,0)); // external acceleration vec_set(cloth_options[28],vector(5,10,5)); // random wind acceleration cloth_options[9] = 4; // Tear Factor cloth_options[37] |= NX_CLF_GRAVITY|NX_CLF_BENDING|NX_CLF_COLLISION_TWOWAY|NX_CLF_SELFCOLLISION|NX_CLF_TEARABLE|NX_CLF_BENDING_ORTHO; pXent_cloth(my,pole,NX_CLOTH_ATTACHMENT_TWOWAY,0,0,cloth_options); } action flag_pole(){ pole = me; vec_set(pole.scale_x,vector(0.2,0.2,40)); vec_set(pole.pan,vector(0,0,0)); vec_set(pole.blue,COLOR_GREY); pXent_settype(pole,PH_STATIC,PH_BOX); } action act_flag_creator(){ set(my,INVISIBLE); ent_create(CUBE_MDL,vector(my.x,my.y,my.z),flag_pole); ent_create("clothflag.mdl",NULL,flag); } function main(){ fps_max = 60; level_load("test1.wmb"); physX_open(); while(1){ if(key_1){ level_load("test1.wmb");} if(key_2){ level_load("test2.wmb");} wait(1); } }
can someone show me where i wrong and explain what happens to physic objects after level load?