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
3 registered members (NewbieZorro, TipmyPip, 1 invisible), 19,045 guests, and 8 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
Page 2 of 2 1 2
Re: Timestep [Re: Superku] #382596
09/09/11 21:32
09/09/11 21:32
Joined: Mar 2009
Posts: 186
V
Valdsator Offline OP
Member
Valdsator  Offline OP
Member
V

Joined: Mar 2009
Posts: 186
Yeah I guess I'll just make sure you can reach every platform on a lower framerate. Worked for Quake. tongue Thanks.

Re: Timestep [Re: Valdsator] #383656
09/23/11 08:56
09/23/11 08:56
Joined: Oct 2008
Posts: 513
Carlos3DGS Offline
User
Carlos3DGS  Offline
User

Joined: Oct 2008
Posts: 513
I myself commited some stupid mistakes when I started using the timestep variable. This is a note for any newbie reading this thread.

1. Remember the order operations are made... () first, /* second, +- last.
in this code:
Code:
my.x += speed + friction * time_step;


timestep will only affect friction, not the speed. to clarify this look at it as if it was doing this:
my.x += speed + (friction*time_step);
to correct this write your code to always make sure timestep will multiply everything like this:
Code:
my.x += (speed + friction) * time_step;



2. While you cant completely get rid of the problem of the different heights (the diagram someone provided earlier ilustrates this problem perfectly) what you can do is force the jump to at least make sure you have reached the desired height before stopping with something like this:
Code:
target_z = my.z + jump_height;
while(my.z < target_z)
{
my.z += jump_speed * time_step;
}



3. Of course when you force the jump to reach the desired height you may run into another problem... If you hit something along the way (ceiling) before reaching the jump height your character will remain "floating" trying to reach his target jump_height. To avoid this make sure you use c_move() for the movement and include a check for getting stuck by a collision in the while() condition.
It would look something like this:
Code:
target_z = my.z + jump_height;
result = 1;
while((my.z < target_z) && (result>0))
{
result = c_move(me,vector(0,0,(jump_speed*time_step)),nullvector,IGNORE_PASSABLE|GLIDE);
}



A note on c_move from the manuall to clarify what "result" is being used for:
Quote:
The c_move function returns the amount of distance covered. If the entity could not move at all due to being blocked by obstacles, it returns a negative value or 0.


Hope this helped someone.


"The more you know, the more you realize how little you know..."

I <3 HORUS
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=401929&page=1
Page 2 of 2 1 2

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