• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Periodic Animation.

Status
Not open for further replies.
Level 15
Joined
Oct 29, 2012
Messages
1,474
Hi guys.
I'm facing many problems these days ... Well I have a movement system that uses loops I mean periodic triggers ( each 0.05 seconds ). Well When some one presses right the unit moves (y'know -_-) . But It moves it instantly without any animations ( just stuck and stopped ) . Well How can I play an unit's animation while it's being moved by a periodic trigger ?
I turned hiveworkshop upside down but I didn't find a useful info . Thanks +rep
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
You could order the unit to play its animation and move it via custom script
  • call SetUnitX(udg_unit_variable, udg_x)
  • call SetUnitY(udg_unit_variable, udg_y)
where reals x and y are x and y coordinates of the point you want that unit to move to.
This will move unit without interrupting its order, so it should not replace currently played animation.

The downside of moving units this way is that those functions ignore map's pathing (i.e. your unit will be moved via unpassable terrain, even out of map, which does not happen with the GUI action)

If you have problem playing unit's walk animation, you could use custom script for it
  • Custom script: call SetUnitAnimationByIndex(udg_unit_variable, Animatino_Index)
  • example
  • Custom script: call SetUnitAnimationByIndex(udg_u, 1)
 
Level 15
Joined
Oct 29, 2012
Messages
1,474
Well Thank you so much , But Ho wcan I know the index of an animation ..I don't know if the animations in Warcraft Preview screen in WE shows them in an order . Also The Point I need the unit to move to is periodic. It 's changed every 0.02 seconds . Well What is the local that makes me move the unit to 'y_of_udg_point_variable' and 'x_of_dg_point_variable' ?
 
You can either view the index by using something like:
http://www.hiveworkshop.com/forums/spells-569/epic-animation-viewer-v1-5-a-200976/
Or you can open the MDL file (convert it to mdl) in notepad and look at where the animations are listed. The animations are listed in order: the first animation takes index 0, the second takes index 1, and so on.

You can always test it in game by doing call SetUnitAnimationByIndex(<unit>, <index number>) in some test map (put in a value for <unit> and for <index number>).

As for the x/y thing, there should be a function that is "X coordinate of point" or "Y coordinate of point". Something like this:
  • Set TempLoc = (Position of (Triggering unit))
  • Set TempX = (X coordinate of TempLoc)
  • Set TempY = (Y coordinate of TempLoc)
Then plug them in as:
JASS:
call SetUnitX(udg_MyUnit, udg_TempX)
call SetUnitY(udg_MyUnit, udg_TempY)
And remember to clean the leak of TempLoc. etc.
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
To find out unit's animation index, you need a program - like WC3 Viewer.
Find your unit in the mpq (or open it if it's a custom unit), in the "Treeview" window (mine is on the left side by default), there is a rolling menu called "Animation". The order in which those animations are listed is the index you use in the custom script. Index starts from the number 0.

An example of Footman's animation indexes:
(null) == this is not animation, so no index for it
Stand - 1 == Index 0
Stand - 2 == Index 1
Stand Victory == Index 2
Stand - 4 == 3
Attack - 1 == 4
Attack - 2 == 5
etc.
 
Level 15
Joined
Oct 29, 2012
Messages
1,474
Then plug them in as:
JASS:
call SetUnitX(udg_MyUnit, udg_TempX)
call SetUnitY(udg_MyUnit, udg_TempY)
And remember to clean the leak of TempLoc. etc.

What does this do ?:goblin_jawdrop::goblin_jawdrop:

EDIIIIIIIIIIIIT : Ok it moves units nvm

Alright ... The Unit doesn't show its animation when moving . I just don't know where I must put the custom script you gave . Should I put it in the loop periodic trigger? Or the trigger that runs the periodic trigger? (I mean player presses x)
 
Last edited by a moderator:
Level 15
Joined
Oct 29, 2012
Messages
1,474
Well this didn't work , Look at this it didn't work :

  • MovementRight
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • -------- Makes the trigger run for each player set to play: --------
      • Set _IntegerR_2D = 1
      • For each (Integer A) from 1 to _AmountPlayers_2D, do (Actions)
        • Loop - Actions
          • -------- Checks so there is no stable ground to the right of the player and that the player is actually moving right: --------
          • Set _tempPointR_2D = (Position of _Hero_2D[_IntegerR_2D])
          • Set _tempPointR2_2D = (_tempPointR_2D offset by _BlockDistance2_2D towards _AngleRight_2D degrees)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • _MovingRight_2D[_IntegerR_2D] Equal to True
              • (Terrain type at _tempPointR2_2D) Not equal to _GroundStable_2D
            • Then - Actions
              • -------- Moves the player to the right: --------
              • Set _tempPointR_2D = (Position of _Hero_2D[_IntegerR_2D])
              • Set _tempPointR2_2D = (_tempPointR_2D offset by _SpeedMove_2D towards _AngleRight_2D degrees)
              • Set _tempPointR_X_2D[_IntegerR_2D] = (X of _tempPointR2_2D)
              • Set _tempPointR_Y_2D[_IntegerR_2D] = (Y of _tempPointR2_2D)
              • Unit - Make _Hero_2D[_IntegerR_2D] face 0.00 over 0.00 seconds
              • Custom script: call SetUnitX(udg__Hero_2D[udg__IntegerR_2D], udg__tempPointR_X_2D[udg__IntegerR_2D])
              • Custom script: call SetUnitY(udg__Hero_2D[udg__IntegerR_2D], udg__tempPointR_Y_2D[udg__IntegerR_2D])
              • Custom script: call SetUnitAnimationByIndex(udg__Hero_2D[udg__IntegerR_2D], 1)
            • Else - Actions
          • Set _IntegerR_2D = (_IntegerR_2D + 1)
      • Custom script: call RemoveLocation( udg__tempPointR_2D )
      • Custom script: call RemoveLocation( udg__tempPointR2_2D )
Well The Unit moves ...The Animation Index is correct ( i tested it ) . But It seems that the animation speed of _Hero_2D (moving unit) is 0.00 % . :/
 
Level 15
Joined
Oct 29, 2012
Messages
1,474
Well thanx it works perfectly (I'm so lazy to add one stupid trigger :/ . Anyways, whatsoever i change the index . It plays one animation that I don't need . Well What must I do? because this trigger doesn't work :
JASS:
call SetUnitAnimationByIndex(udg__Hero_2D[udg__IntegerR_2D], 1)

_Hero_2D = Unit being moved
_IntegerR_2D = Player Number Of Triggering Player
1 = Index of the animation that is asumed to be played
 
Well you are playing it every 0.02 seconds so it will probably look really jittery. You should just put that code once when you start the periodic trigger. If you need to loop it, then you have to make a variable to keep track of the duration passed (real variable). When the trigger starts, set the animation time variable to the time it takes to do the animation. Each tick in the periodic trigger, set the duration to duration - 0.02. If the duration becomes less than or equal to 0, then set the duration back to the original animation time and play the animation again.

EDIT: Nevermind. Read maker's post:
http://www.hiveworkshop.com/forums/2377536-post16.html
 
Last edited:
Status
Not open for further replies.
Top