Returns a value representing the moving speed of a unit. Added in Patch 3.0.1.
currentSpeed, runSpeed, flightSpeed, swimSpeed = GetUnitSpeed(unit)
Arguments
- unit
- String (unitId) - Unit to query the speed of. This has not been tested with all units but does work for "player" units.
Returns
- currentSpeed
- number - current movement speed in yards per second (normal running: 7; an epic ground mount: 14)
- runSpeed
- number - the maximum speed on the ground, in yards per second (including talents such as Pursuit of Justice and ground mounts)
- flightSpeed
- number - the maximum speed while flying, in yards per second (the unit need to be on a flying mount to get the flying speed)
- swimSpeed
- number - the maximum speed while swimming, in yards per second (not tested but it should be as the flying mount)
Example
The following snippet prints your current movement speed in percent:
/script print(string.format("Current speed: %d%%", GetUnitSpeed("player") / 7 * 100))
Notes
As of 4.2, runSpeed, flightSpeed, swimSpeed returns were added. It seem you can also get target unit speed (not tested on the opposite faction).
A constant exists: "BASE_MOVEMENT_SPEED" which is equal to 7 (4.2).