Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
3 registered members (TedMar, AndrewAMD, fairtrader), 578 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
correct way to accelerate #138773
06/29/07 10:08
06/29/07 10:08
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline OP
Expert
Joey  Offline 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] #138774
06/29/07 10:44
06/29/07 10:44
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
does you accelerate for one frame only or as long as you hold space?

if you accelerate for 1/10th second of course you will be faster than if you accelerate for 1/60th second for example. try to compensate that!

Re: correct way to accelerate [Re: ventilator] #138775
06/29/07 11:24
06/29/07 11:24
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline
User
demiGod  Offline
User

Joined: Mar 2006
Posts: 752
Portugal
Dont know if this can help you, but sometime ago i used vec_accelerate for camera movement and it seems to be very accurate, didnt used time_step though. iSpeed is the speed factor.


vAccel.x = iSpeed * (key_w - key_s);
vAccel.y = iSpeed * (key_a - key_d);
vAccel.z = iSpeed * (key_home - key_end);
vec_accelerate(vMove, vSpeed, vAccel, 0.5);
c_move(my, vMove, nullvector, glide);

Re: correct way to accelerate [Re: demiGod] #138776
06/29/07 14:18
06/29/07 14:18
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline OP
Expert
Joey  Offline OP
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
it gets applied only once (one frame). the result of not using time_step (like in your example) is that the player jumps damn high.

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 Offline
User
tompo  Offline
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: tompo] #138778
06/29/07 17:28
06/29/07 17:28
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline OP
Expert
Joey  Offline OP
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
weird enough, when you look at the code sample which can be found at the "accelerate"-function, there's made use of time_step, exactly as i would expect it to be used. but still, it's not framerate independent.

what if i want to go multiplayer and the entities get accelerated differently on different machines? weird...

Re: correct way to accelerate [Re: Joey] #138779
06/29/07 22:19
06/29/07 22:19
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
i think it's like i said. it is framerate independent * if you accelerate continuously but not if you accelerate one frame only. think about the formula in the manual. won't the result be bigger in a big time step?

* not 100% but it should be close - for multiplayer you shouldn't work like that anyway



for example if you accelerate while holding a button for 3 seconds then it doesn't matter if it happens in 30 steps (frame rate 10) or 180 smaller steps (frame rate 60) but if you accelerate for one frame only then there will be a difference of course!

i just would set the z speed directly for jumping.

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 Offline OP
Expert
Joey  Offline 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: Joey] #138781
06/30/07 10:24
06/30/07 10:24
Joined: Mar 2005
Posts: 969
ch
Loopix Offline
User
Loopix  Offline
User

Joined: Mar 2005
Posts: 969
ch
Not that this is a solution...but once it helped me (when using accelerate) to set the time_smooth variable (can be 0.9)?

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 Offline
Senior Expert
ventilator  Offline
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.

Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | 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