Page 1 of 1
Can i get unit current speed?
Posted: 03 May 2010, 11:39
by slogic
I have looked through AI interface and all i can get is unit max speed. Is there some way to get unit CURRENT speed? Actually i need to know if unit is moving or not. Scanning its command queue for MOVE command is not tasty for me. Also i don't know if it will work for allied teams.
Re: Can i get unit current speed?
Posted: 03 May 2010, 12:28
by hoijui
Unit.h does not have a field speed or current-speed or something.
How i think it works:
For each frame, the engine calculates how far the unit will get, according to its move-type, the terrain, a limit that says, do not move faster then unit X, ...
so the current speed changes each frame, but it is not saved in a variable, and you could just as well calculate it by tracing the units position. There should be little overhead there.
Re: Can i get unit current speed?
Posted: 03 May 2010, 15:46
by slogic
Isn't in simulation code it is calculated anyway? Just store it in a unit and expose to public. Calculation of speed per each AI type is stupid (if they really needed this info).
Re: Can i get unit current speed?
Posted: 05 May 2010, 16:28
by slogic
FYI, Kloot was so responsive that added this possibility in master with
http://github.com/spring/spring/commit/ ... e3c96c30f8 commit.
Re: Can i get unit current speed?
Posted: 05 May 2010, 16:51
by Satirik
Kloot is awesome !