|
|
correct way to accelerate
#138773
06/29/07 10:08
06/29/07 10:08
|
Joined: Jan 2003
Posts: 4,615 Cambridge
Joey
OP
Expert
|
OP
Expert
Joined: Jan 2003
Posts: 4,615
Cambridge
|
hey! i hope you can help me with the following problem. i've written a script which accelerates a model. now i want to have the acceleration fps-independent. have a look at the following: [space] is pressed, force.z is set to 5 (jumping). i use vec_accelerate to calculate the acceleration for the model: Code:
vec_accelerate(temp, my.vel, force, 0.8);
which variables do i need to multiplicate with time_step to gain the required independence? i've tried dividing force through time_step, this makes the distance covered by the model independent (always the same distance). but the movement is too slow. same if i divide force through time_step twice and later on multiply temp by time_step. the problem is, if i set fps_max to 10 for example, i can suddenly jump way too high if i leave all the variables untouched by time_step. i'm stuck here and hope you can point me in the right direction, thanks, joey.
Last edited by Joey; 06/29/07 10:10.
|
|
|
Re: correct way to accelerate
[Re: Joey]
#138777
06/29/07 14:46
06/29/07 14:46
|
Joined: Mar 2007
Posts: 776 Poor village - Poland ;)
tompo
User
|
User
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
|
I've read in help that: speed - current speed vector in quants per tick. This value is changed by the acceleration accel - acceleration vector in quants per square tick So everything is attached with ticks?!
maybe try with time not cycles like wait(-0.1); time is constant... or change to my.speed += value *time_step; to have fps-independent?
Last edited by tompo; 06/29/07 14:46.
Never say never.
|
|
|
Re: correct way to accelerate
[Re: ventilator]
#138780
06/30/07 10:00
06/30/07 10:00
|
Joined: Jan 2003
Posts: 4,615 Cambridge
Joey
OP
Expert
|
OP
Expert
Joined: Jan 2003
Posts: 4,615
Cambridge
|
Quote:
i just would set the z speed directly for jumping.
so you think this is some kind of rounding error? the entity jumps approximately 5 times as high, is that possible? if so, is that what you said how things should be done in multiplayer?
thanks, ventilator!
|
|
|
Re: correct way to accelerate
[Re: Loopix]
#138782
06/30/07 11:28
06/30/07 11:28
|
Joined: May 2002
Posts: 7,441
ventilator
Senior Expert
|
Senior Expert
Joined: May 2002
Posts: 7,441
|
no, it's not a rounding error. acceleration depends on how long you do it.  if you accelerate over multiple frames (like you should) then the result will be the same with different frame rates: Code:
|-----|-----|-----| |-|-|-|-|-|-|-|-|-|
(but if the frame rate isn't an exact multiple then there will be a small error. it will only be 97.5% frame rate independent or so.  ) if you do it one frame only then the result won't be the same: Code:
|-----| |-|
i hope this makes it clearer? ... i don't really know what you want to do in multiplayer but i think you should never work with relative stuff which can accumulate an error after a while at the individual clients.
|
|
|
|