getting unit speed/direction beside GetUnitVelocity
Posted: 07 Feb 2011, 12:17
If I didnt miss anything, at the moment the only way to get a units speed is Spring.GetUnitVelocity which returns a vector.
So to get the unitspeed as a number, you have to calculate the length of this vector.
But there is still no way to know if the unit is driving forwards or backwards. Beside maybe comparing the speed vector with the heading vector. (checking if they point in same direction)
This seems like a bit of unnessecaty calculations and iam not sure how accurate it would because you would have to do it at intervalls.
Knowing forward/backward movement is important for animations ie reverse walking animations or spin wheels backwards.
So I think it would be good to have:
Spring.GetUnitSpeed (unitID)
it would return the unit speed as a number, compatible to the numbers in unitdef and if the unit is driving backwards it is negative.
In unit animation scripts there are the StartMoving() and StopMoving() callins.
Maybe these callins could also include the units speed and the units wanted speed.
So that you do not have to GetUnitSpeed and do not have to poll the speed in a loop to check for changes.
Similiar to how to
script.WindChanged ( number heading, number strength )
also includes heading+strength even though there is Spring.GetWind () too.
So to get the unitspeed as a number, you have to calculate the length of this vector.
But there is still no way to know if the unit is driving forwards or backwards. Beside maybe comparing the speed vector with the heading vector. (checking if they point in same direction)
This seems like a bit of unnessecaty calculations and iam not sure how accurate it would because you would have to do it at intervalls.
Knowing forward/backward movement is important for animations ie reverse walking animations or spin wheels backwards.
So I think it would be good to have:
Spring.GetUnitSpeed (unitID)
it would return the unit speed as a number, compatible to the numbers in unitdef and if the unit is driving backwards it is negative.
In unit animation scripts there are the StartMoving() and StopMoving() callins.
Maybe these callins could also include the units speed and the units wanted speed.
So that you do not have to GetUnitSpeed and do not have to poll the speed in a loop to check for changes.
Similiar to how to
script.WindChanged ( number heading, number strength )
also includes heading+strength even though there is Spring.GetWind () too.