even minor lag strongly affects physics, what am I doing wrong?

Posted By: thegamedesigner

even minor lag strongly affects physics, what am I doing wrong? - 01/12/10 15:58

Even minor lag, strongly affects my player's movement (it's a marble). I get the impression I'm just doing something wrong.


Ok, so here is a (cut down version) my player action:

action player_act
{
...
player = my;
...
while(1)
{
...
phent_settype(my,ph_rigid,ph_sphere);
phent_setmass(my,10,ph_sphere);
phent_setfriction (my, 0);
phent_setdamping(my, 90, 30);
phent_setelasticity (my, 0, 20);
phent_setgroup(my, 1);
ph_selectgroup(1);

//moving
vec_set(dir,nullvector);
if(key_a == 1){dir.y+=1;}
if(key_d == 1){dir.y-=1;}
if(key_s == 1){dir.x-=1;}
if(key_w == 1){dir.x+=1;}

vec_set(tempvec1,camera.pan);
tempvec1[1] = 0;
vec_rotate(dir,tempvec1);
vec_normalize(dir,10000*time);
phent_addforceglobal(my,dir,my.x);

vec_set(dir,nullvector);
dir.z = 1;
vec_normalize(dir,100000*time);

phent_addforceglobal(my,dir,my.x);
...
wait(1);
}
...
}


Everything else in my game runs fine, because I use * time. I've not been able to get this effect with physics, even a small blip will cause the player to jump three times as high.

Any help? I'm sure this is my fault, I'm just looking to learn people's methods for dealing with this?
Posted By: Helghast

Re: even minor lag strongly affects physics, what am I doing wrong? - 01/12/10 16:26

* time is old code... use * time_step instead!

regards,
Posted By: thegamedesigner

Re: even minor lag strongly affects physics, what am I doing wrong? - 01/12/10 16:36

Fine, but I didn't mean that. *time is working fine in the rest of my game. I just meant I don't know how to use *time (or *time_step) in physics.

Should I be doing add_force * time_step? I didn't think that worked?

I want my physics to not go crazy at the slightest lag. I don't know how. Should I lock the FPS? Should I use time_step? Can someone give me an example of physics movement on a marble that stays the same even though the frame rate dips?
© 2024 lite-C Forums