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!