|
#define UNITS_PER_HUNDREDTH_OF_A_SECOND 1
#define UNITS_PER_RENDER 2
This function is only relevant for object that have their chase type set to
CHASE_TRAKE or CHASE_TRACK_AIRPLANE or CHASE_PHYSICS (relevant for CHASE_PHYSICS
only when collison detection for chase physics is turned off. See STATE_object_cancel_collision_test_for_chase_physics() for more details)
When objects are set to go according to a specific track
they have speed. We have two ways two work with the speed. The given speed could be render cycle related or
time related. The default is according to time (UNITS_PER_HUNDREDTH_OF_A_SECOND).
We recommend not to use the default and to call this function after loading the world with UNITS_PER_RENDER
(example STATE_object_set_speed_units(UNITS_PER_RENDER) );
If you want to make your world based on time you should use STATE_engine_get_computer_speed_factor() instead.
The reason why we recommend not using UNITS_PER_HUNDREDTH_OF_A_SECOND is because
when using UNITS_PER_HUNDREDTH_OF_A_SECOND the engine checks the Windows system clock every render
in order to calculate the correct advancement that should be applied. The problem is that
the Windows system clock might not be updated as frequently as FPS of the application.
For example if there are 100 frames per second in your game and the system clock is updated
only ten times a second, the result will be that the object will move only in every tenth of a second ...
To solve this you should alaways work according to render cycles but in order to make your
program run the same on every computer you should use STATE_engine_get_computer_speed_factor()
at the beginning of your program to determine the computer speed.
Parameters:
1- UNITS_PER_HUNDREDTH_OF_A_SECOND
This is the default mode. The advantage of this mode is that
objects will move at the same speed no matter what is the size of the world
or the strength of the computer. On slower computers the objects will simply
move in bigger steps thus make the movement less smooth.
For example an object that has an absolute speed of 10 will
move in a speed of 10 units per 1 hundredth of a second which means
1000 virtual units in a second.
2-
UNITS_PER_RENDER
Each render the object is advance by the speed, notice that we will
get a different speed for slow computers than on fast ones, though
the steps that the object is doing each render will always be equal.
The default is UNITS_PER_HUNDREDTH_OF_A_SECOND.
Remarks:
* The speed_units_system is always set for all the objects.
Question: What is the length of one virtual unit ?
Answer: This depends on your world. For example lets say that your world
is just one big house. When you build this house in a 3D editor
you can make the length of the house 1 million units or maybe just 100 units
it is up to you. You decide what is the length of one unit inside your world.
The engine doesn't care whether you have chosen to build your world so that one unit is
equal to one meter, one centimeter or one inch.
|