• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

how to play units walk animation

Status
Not open for further replies.
Level 23
Joined
Apr 16, 2012
Messages
4,041
Im creating "Charge" spell and i want it to look somehow not just oo you slide to your target and kick his balls.
How to play units animation? Ive tried:
JASS:
function theloopone takes nothing returns nothing
    //blablabla
    call SetUnitAnimation(u, "walk") //u is the unit
    //also tried
    call QueueUnitAnimation(u, "walk")
    //blabla, cleaning leaks etc
endfunction

function Start takes nothing returns nothing
    //blabla
    call SetUnitAnimation(GetTriggerUnit(), "walk")
    //blabla, cleaning leaks etc
endfunction
(The unit is currently Mountain King)
he only slides and only when i did call SetUnitAnimation in both he did get his one leg to air but he freezes at that point again. :(
any help(The theloopone runs 50 times/sec)
Also when he finishes charging he plays attack animation even through the animation in object editor is walk and even if I reset the animation or pause the unit
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
It should be SetUnitAnimationByIndex(whichUnit, whichInteger)
That function does not interrupt order, so you can order your Mountain King to play its Walk animation but does not interrupt order (meaning that it will keep playing the Walk animation until you tell him to change Animation)

All units have their own Animation Index number, such as 0 for Walk, 1 for Attack 1, 2 for Attack 2, 3 for Death, and so on.

First, you must run a test to acknowledge yourselves what Integer does "Walk" animation of Mountain King belongs to, here's the simple test;
  • Untitled Trigger 001
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Set u = Mountain King 0002 <gen>
      • Custom script: call SetUnitAnimationByIndex(udg_u, udg_i)
      • Game - Display to (All players) the text: (String(i))
      • Set i = i + 1
Each time you press ESC key, it will play the unit's animation according to current integer (initially 0).
Keep testing which Integer is your "Walk" animation, until you found it, let's say it's 3.

Now, you just need to do this;
  • Custom script: call SetUnitAnimationByIndex(udg_u, 3)
Usually, a slide trigger should consist of SetUnitX/Y + SetUnitAnimationByIndex + Order the unit to stop per interval.

Example;
  • Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to YourAbility
    • Actions
      • Set u = (Triggering unit)
      • Custom script: call SetUnitAnimationByIndex(udg_u, 3)
      • Trigger - Turn on Loop <gen>
  • Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set TempLoc = (Position of u)
      • Set TempLoc2 = (TempLoc offset by 15.00 towards (Facing of u) degrees)
      • Custom script: call SetUnitX(udg_u, GetLocationX(udg_TempLoc2))
      • Custom script: call SetUnitY(udg_u, GetLocationY(udg_TempLoc2))
      • Unit - Order u to Stop
      • Custom script: call RemoveLocation(udg_TempLoc)
      • Custom script: call RemoveLocation(udg_TempLoc2)
 
Status
Not open for further replies.
Top