Crash physX

Posted By: Rik

Crash physX - 09/19/10 12:38

Hi...
I'm trying to create a small game, but i have some problem with physX.
If i use c_move the game work.
But if i want to move the entity with physX i have error E1513:script crash in ball(). Can anyone help me?
the code:
Click to reveal..
#include <acknex.h>
#include <default.c>
#include <ackphysx.h>
SOUND* sound1 = "sound.ogg";
VECTOR* vector1;
function camera_seg(ENTITY* ent)
{
vec_set(camera.x,vector(-45,0,15));
vec_rotate(camera.x,ent.pan);
vec_add(camera.x,ent.x);
vec_set(camera.pan,vector(ent.pan,0,0));
}
function move(ENTITY* enti)//function that work
{
if (key_a) my.pan += 10*time_step;
if (key_d) my.pan -= 10*time_step;
if (key_w) c_move(me,vector(10*time_step,0,0),NULL,GLIDE);
if (key_s) c_move(me,vector(-10*time_step,0,0),NULL,GLIDE);
}
function main()
{
physX_open();
screen_size.x = 1024;
screen_size.y = 768;
mouse_mode = 4;
level_load("liv_2.wmb");
}
action ball()//don't work
{
pXent_settype(me,PH_RIGID,PH_SPHERE);
pXent_enable(me,1);
pXent_setfriction(me,50);
ent_playsound(my,sottofondo,100);

while (1)
{
camera_seg(my);
vector1.x = (key_cur-key_cul)*10*time_step;
vector1.y = (key_cuu-key_cud)*10*time_step;
vector1.z = 0;
pXent_addtorqueglobal(me,vector1);
wait(1);
}

}

Posted By: Quad

Re: Crash physX - 09/19/10 12:42

most likely, your level has more then 65k polys(update to latest beta to fix)
Posted By: Rik

Re: Crash physX - 09/19/10 18:41

I have the latest version.... Anything else? frown
Posted By: painkiller

Re: Crash physX - 09/19/10 18:52

if (key_a) my.pan += 10*time_step;
if (key_d) my.pan -= 10*time_step;
if (key_w) c_move(me,vector(10*time_step,0,0),NULL,GLIDE);
if (key_s) c_move(me,vector(-10*time_step,0,0),NULL,GLIDE);

lol you can't do this in a physic entity, take a look at the physics workshop
Posted By: Pappenheimer

Re: Crash physX - 09/19/10 18:57

Same procedure as every time: reduce the code to a minimum:

action ball()
{
pXent_settype(me,PH_RIGID,PH_SPHERE);
pXent_enable(me,1);
pXent_setfriction(me,50);
}

...and build it up again line by line.
You can compare it to the sample earthball8.c where the ball is created after loading the level within the main function. I guess you placed it in WED in the level? Shouldn't make a difference though.

Is your ball a model (mdl) or a level entity (wmb)? Maybe, that's a problem.
Posted By: Rik

Re: Crash physX - 09/20/10 11:02

i change the code... This is the new...
Click to reveal..

#include <acknex.h>
#include <default.c>
#include <ackphysx.h>
SOUND* music = "sottofondo.ogg";
VECTOR* vector1;
ENTITY* ball;
function camera_seg(ENTITY* ent)
{
vec_set(camera.x,vector(-45,0,15));
vec_rotate(camera.x,ent.pan);
vec_add(camera.x,ent.x);
vec_set(camera.pan,vector(ent.pan,0,0));
}

function main()
{
physX_open();
screen_size.x = 1024;
screen_size.y = 768;
mouse_mode = 4;
level_load("liv_2.wmb");
ball = ent_create("palla_gialla.mdl",vector(-556,-88,-104),NULL);
ent_playsound(ball,music,100);
pXent_enable (ball,1);
pXent_settype (ball,PH_RIGID,PH_SPHERE);
pXent_setfriction (ball,50);
while (1)
{
camera_seg(ball);
vector1.x = (key_cur-key_cul)*10*time_step;
vector1.y = (key_cuu-key_cud)*10*time_step;
vector1.z = 0;
pXent_addtorqueglobal (ball, vector1);
wait(0.1);
}
}
The debug show this error: error E1513 Script crash in main: SYS.
The script show the window and play the music... So i think that the error is in pXent_settype....
Any hint??? frown

Posted By: muffel

Re: Crash physX - 09/20/10 12:43

I think I have found your error.

You declare the global POINTER vector1.
This vector1 is pointing to nowhere.
No memory is allocated for this vector1
Now you write in your ball/main funktion to nonexisting/not allocated memory.
This causes the crash.

How you solve it??
Delete the "*" in your "VECTOR* vector1" line.
and the problem of the crash is solved.
PhysX has nothing to do with that

corrected code
Click to reveal..

Code:
#include <acknex.h>
#include <default.c>
#include <ackphysx.h>
SOUND* music = "sottofondo.ogg";
//////
VECTOR vector1; //////// here was the mistake
//////
ENTITY* ball;
function camera_seg(ENTITY* ent)
{
vec_set(camera.x,vector(-45,0,15));
vec_rotate(camera.x,ent.pan);
vec_add(camera.x,ent.x);
vec_set(camera.pan,vector(ent.pan,0,0));
}

function main()
{
physX_open();
screen_size.x = 1024;
screen_size.y = 768;
mouse_mode = 4;
level_load("liv_2.wmb");
ball = ent_create("palla_gialla.mdl",vector(-556,-88,-104),NULL);
ent_playsound(ball,music,100);
pXent_enable (ball,1);
pXent_settype (ball,PH_RIGID,PH_SPHERE);
pXent_setfriction (ball,50);
while (1)
{
camera_seg(ball);
vector1.x = (key_cur-key_cul)*10*time_step;
vector1.y = (key_cuu-key_cud)*10*time_step;
vector1.z = 0;
pXent_addtorqueglobal (ball, vector1);
wait(0.1);
}
}




Hope you understand my explanation

EDIT:funny how complicated you think. Just because he says PhysX is the problem

muffel
Posted By: Rik

Re: Crash physX - 09/21/10 17:39

Yes.... The error is in VECTOR*...
Thank you so much.... laugh
© 2023 lite-C Forums