2 registered members (Akow, tomaslolo),
1,536
guests, and 12
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
empty pointer?
#224021
08/28/08 01:16
08/28/08 01:16
|
Joined: Jul 2008
Posts: 37 Ankara, Turkey
Warchief
OP
Newbie
|
OP
Newbie
Joined: Jul 2008
Posts: 37
Ankara, Turkey
|
hi when i run these codes, it says empty point, waht is problem? #include <acknex.h>
#include <default.c>
ENTITY* carbody;
ENTITY* tireleft;
var joinbody;
action mybody()
{
carbody=me;
phent_settype (my, PH_RIGID, PH_BOX);
phent_setmass (my, 70, PH_BOX);
phent_setgroup (my, 2);
phent_setfriction (my, 20);
phent_setdamping (my, 40, 40);
phent_setelasticity (my, 50, 20);
}
action lefttire()
{
tireleft=me;
phent_settype (my, PH_RIGID, PH_SPHERE);
phent_setmass (my, 10, PH_SPHERE);
phent_setgroup (my, 2);
phent_setfriction (my, 60);
phent_setdamping (my, 40, 40);
phent_setelasticity (my, 50, 20);
joinbody= phcon_add( PH_WHEEL, carbody, my);
phcon_setparams1 (joinbody, my.x, vector(0, 0, 1), vector(1, 0, 0));
phcon_setparams2 (joinbody, vector(-30, 30, 0), nullvector, vector(50000, 100, 0));
}
void main()
{
level_load("test.wmb");
wait(4);
ph_setgravity (vector(0, 0, -386));
while(1)
{
if(key_w == 0 & key_s == 0 & key_a == 0 & key_d == 0)
{
phcon_setmotor(joinbody, vector(0,50,0), nullvector, nullvector);
}
if(key_a == 1&key_d == 0)
{
phcon_setmotor(joinbody, vector(-100,50,0), vector(0,0,0), nullvector);
}
wait(1);
}
}
Vekare
|
|
|
Re: empty pointer?
[Re: Warchief]
#224034
08/28/08 05:02
08/28/08 05:02
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
There is the potential for the function "action lefttire" to run BEFORE carbody has been filled. So I would insert the folowing code
action lefttire()
{
tireleft=me;
//
while(carbody==NULL) wait(1); //<<<< Line to insert
//
phent_settype (my, PH_RIGID, PH_SPHERE);
This way the tyre code will wait until the carbody exists before it tries to join with it. In reality, this line could be placed anywhere in you code as long as it comes before the "joinbody= phcon_add( PH_WHEEL, carbody, my);" line. But where Ive got it, I think there will be less load on the physics engine when there is no carbody.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: empty pointer?
[Re: Warchief]
#224187
08/29/08 01:37
08/29/08 01:37
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
What was it, spelling typo?
Your description on "re-define pointer" isnt too clear.
And do you mean the problem is actually solved, or just the error goes away?
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: empty pointer?
[Re: EvilSOB]
#224190
08/29/08 03:10
08/29/08 03:10
|
Joined: Jul 2008
Posts: 37 Ankara, Turkey
Warchief
OP
Newbie
|
OP
Newbie
Joined: Jul 2008
Posts: 37
Ankara, Turkey
|
completely solved, and i mean with re-defined was, i delete entity and defined it again.
Vekare
|
|
|
Re: empty pointer?
[Re: Warchief]
#224191
08/29/08 03:19
08/29/08 03:19
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Ah, I get it. Best of luck.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
|