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
1 registered members (AndrewAMD), 599 guests, and 3 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 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 | 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