2025-07-30 08:51 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0002344Spring engineLuapublic2011-02-21 19:40
Reporteruser744 
Assigned ToKloot 
PrioritynormalSeverityfeatureReproducibilityN/A
StatusresolvedResolutionfixed 
Product Version0.82.7.1 
Target VersionFixed in Version0.82.7+git 
Summary0002344: Req: GetUnitSpeed (uID) -> returns number and StartMoving (speed)
DescriptionIf 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 because the length is unsigned. 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.

Telling apart 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.
Or maybe signed speed could just be a fourth return parameter to GetUnitVelocity(), whatever is easier/better.

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.

It would make some scripts very simple ie:

script.StartMoving (speed)
  Spin (Wheel, bla_axis, speed*somefactor)
end
Additional Informationhttp://springrts.com/phpbb/viewtopic.php?f=21&t=25308
had previously made thread in forum in case someone was going to post its already possible
TagsNo tags attached.
Checked infolog.txt for Errors
Attached Files

-Relationships
+Relationships

-Notes

~0006423

user744

kloot added something :)
https://github.com/spring/spring/commit/3089a9da1769d3d9b1c42b74c5d29c852495240d

~0006424

Kloot (developer)

Last edited: 2011-02-21 19:40

indeed (and I assume that change plus GetUnit{COB}Value(..., REVERSING) is enough to meet your modding needs)

+Notes

-Issue History
Date Modified Username Field Change
2011-02-09 07:14 user744 New Issue
2011-02-21 18:45 user744 Note Added: 0006423
2011-02-21 19:39 Kloot Note Added: 0006424
2011-02-21 19:40 Kloot Note Edited: 0006424
2011-02-21 19:40 Kloot Status new => resolved
2011-02-21 19:40 Kloot Fixed in Version => 0.82.7+git
2011-02-21 19:40 Kloot Resolution open => fixed
2011-02-21 19:40 Kloot Assigned To => Kloot
+Issue History