Automated updating of API pages at this location, to reflect patch changes, has ceased from 10.1.7 onwards. |
Returns the movement speed of the unit.
currentSpeed, runSpeed, flightSpeed, swimSpeed = GetUnitSpeed(unit)
Arguments[]
- unit
- string : UnitId - The unit to query the speed of.
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: %.2f%%", GetUnitSpeed("player") /7 *100))
Details[]
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).