Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
5 registered members (Dico, AndrewAMD, TipmyPip, NewbieZorro, Grant), 15,253 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
A7 physics - no worky on ent_create-ed models #143416
07/26/07 03:46
07/26/07 03:46
Joined: Aug 2006
Posts: 41
Racine, WI, USA
dreadFusemonkey Offline OP
Newbie
dreadFusemonkey  Offline OP
Newbie

Joined: Aug 2006
Posts: 41
Racine, WI, USA
This is in Lite-C, but it's about physics, so I hope it's appropriate to post here...

I have an action function that I apply to models that I've manually added to my level via WED. When I run the level, the physics stuff that I implemented in the action cause the models to act as expected. The model falls to the ground because of gravity, and when i apply force to it, it does it's thing. Everyone's happy.

However, when I create an entity of the same model using ent_create, and apply the same action, it does not work. It does not fall to the ground, and the force I apply does nothing whatsoever.

Attached is the code I am using. Can anyone here explain and solution this phenomenon? Why does manual creation work, but not dynamnic/on-the-fly creation?

Thanks.

Code:

void main(){

...
ent_create("thingydoo.mdl", vector(-1405,-264,210), myPhysics);
wait(1);
...
}


action myPhysics()
{
my.eflags |= (FAT|NARROW);
wait(1);
c_setminmax(me);
my.emask |= (ENABLE_ENTITY|ENABLE_IMPACT); //|ENABLE_FRICTION
my.flags |= (CAST|SHADOW);
my.alpha = 0;
my.event = apply_physics; // when it collides with something, its event function will run
my.scale_x=1.5;
my.scale_y=1.5;
my.scale_z=1.5;
temp.x = 0;
temp.y = 0;
temp.z = -386; // earth gravity factor, g = 9.81 m/s2
ph_setgravity(temp); // set gravity...crashes if i do this in main :/
phent_settype(my, PH_RIGID, PH_BOX);
phent_setmass(my, 2.0, PH_POLY);
phent_setfriction(my, 80); //play with this
phent_setelasticity(my, 1, 25); //play with this
phent_setdamping(me,20,40); //play with this
wait(-3); // let gravity kick in...works on manual entities, but not ent_created for some reason
phent_enable(my,0); /// disable physics on this entity until apply_physics is triggered

}

function apply_physics()
{
// In this case, I am going to apply a force if i was collided with
// by a model containing the text "bullet" in the filename ( a bullet model )
if( str_stri(str_for_entfile(NULL,you),"bullet") > 0 ) {
wait(1);
phent_enable(my,1); // re-enable
phent_addforceglobal(my,vector(75,75,500),normal); //mess with these numbers
if( !snd_playing(hThump) ) {
hThump = ent_playsound(my,SND_THUMP,1000);
}

/// more code here to remove the physic object...
//wait(-6);
//phent_enable(my,0); // mot sure if necessary since we're about to remove the entity
//ent_remove(my);
}
}




To crush your enemy...see them driven before you, and to hear da lamentation of da vimmen!
Re: A7 physics - no worky on ent_create-ed models [Re: dreadFusemonkey] #143417
07/26/07 05:13
07/26/07 05:13
Joined: Apr 2007
Posts: 582
Germany
Poison Offline
User
Poison  Offline
User

Joined: Apr 2007
Posts: 582
Germany
put that thinks into a function;
Code:
 
ph_setgravity(temp); // set gravity...crashes if i do this in main :/
phent_settype(my, PH_RIGID, PH_BOX);
phent_setmass(my, 2.0, PH_POLY);
phent_setfriction(my, 80); //play with this
phent_setelasticity(my, 1, 25); //play with this
phent_setdamping(me,20,40); //play with this
wait(-3); // let gravity kick in...works on manual entities, but not ent_created for some reason
phent_enable(my,0); /// disable physics on this entity until apply_physics is triggered




Everything is possible, just Do it!
Re: A7 physics - no worky on ent_create-ed models [Re: Poison] #143418
07/26/07 08:15
07/26/07 08:15
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
i'm afraid there's no reason for that to fix it.

do you mind showing us all of the main function? it might have something to do with level_load and wait.

everything else looks basically fine from here.

julz


Formerly known as JulzMighty.
I made KarBOOM!
Re: A7 physics - no worky on ent_create-ed models [Re: JibbSmart] #143419
07/27/07 00:22
07/27/07 00:22
Joined: Aug 2006
Posts: 41
Racine, WI, USA
dreadFusemonkey Offline OP
Newbie
dreadFusemonkey  Offline OP
Newbie

Joined: Aug 2006
Posts: 41
Racine, WI, USA
I got it to work, but unfortunately, I am not very happy about the solution. Not something I can't live with, however, and overall it's good enough. Perhaps there is a simpler solution - some overlooked flag or something related to my world or terrain or something.

Anyway, one thing I tried was copy the code out of the earthball demo that dealt with the creation of the earthball and applying the earthball physics stuff to it. Didn't work - earth just hung in the air, and was passable. So, I went back to the drawing board, and modeled my main() after the earthball demo. Instead of loading a World created in WED that contained a terrain and a few miscellaneous models, I instead loaded my terrain directly with level_load, then added the earthball model via ent_create and applied all of the earthball demo physics. Aha - It worked! The earth falls out of the sky and bounces gently to my terrain.

By the time all was said and done, I had my own physics scripts and models working happily together. I now load an empty world with level_load, and add all models, including the terrain, via ent_create. Of course, it took some head-scratching and tweaking to get all of the other stuff that was working, working again, too.

So, is that it? if I want dynamically generated physics objects to work properly then I cannot use a world, complete with a terrain and static entities, pre-baked in WED?


To crush your enemy...see them driven before you, and to hear da lamentation of da vimmen!
Re: A7 physics - no worky on ent_create-ed models [Re: dreadFusemonkey] #143420
07/27/07 05:47
07/27/07 05:47
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
did your pre-baked WED level have a sky-box around it?

perhaps the entity was being created out of the level bounds (a sky-box is a good way to set the level bounds).

good luck,

julz


Formerly known as JulzMighty.
I made KarBOOM!
Re: A7 physics - no worky on ent_create-ed models [Re: JibbSmart] #143421
07/27/07 14:05
07/27/07 14:05
Joined: Aug 2006
Posts: 41
Racine, WI, USA
dreadFusemonkey Offline OP
Newbie
dreadFusemonkey  Offline OP
Newbie

Joined: Aug 2006
Posts: 41
Racine, WI, USA
I was adding the skybox using ent_createlayer w/ the SKY flag. I haven't tried adding the skybox via WED. I'll give that a try.

Last edited by dreadFusemonkey; 07/27/07 15:34.

To crush your enemy...see them driven before you, and to hear da lamentation of da vimmen!

Moderated by  HeelX, Spirit 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1