• 🏆 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!

[Trigger] Playing animation from offset

Status
Not open for further replies.
Level 28
Joined
Jun 4, 2007
Messages
1,479
Hay

I'm making a strafing system for a map and I'm having som issues with animations. The thing is that units don't walk sideways (appart from crabs), so I solved it by making a looping move trigger. During the looping movement I want the walk animation to play (Marine model).
Now playing the animation every 0.02 seconds doesn't work too well so I made a lil' system that plays the animation manually. Then I realised there is no trigger action for playing animations from offset (like you can start music from 10 sec into the track).
I think I saw a "Play animation from offset" action in WEU a few years ago and in that case it could be possible to do with a custom script. But my knowledge in custom scripts is easily compared with the word "ZERO".

Summary: I need a cutsom script that plays animations from offset, if possible.
Thanks in advande.
 
Level 15
Joined
Jul 6, 2009
Messages
889
Interesting situation. Off the top of my head, my approach would be to increase the animation time scale to a really high number and stop when the desired frame is achieved. But is there a maximum animation speed? This still wouldn't make the animation being played from offset, are there any other solutions?

I also want to know how to do this.
 
Level 14
Joined
Aug 30, 2004
Messages
909
If you move a unit using the standard "move unit" action in the world editor, it resets orders and (I believe) resets the animation. That will suck. There is a way around it I believe, using custom script. I don't know JASS either, but sometimes one or two lines is good enough. Use the action Custom script and put these two lines in when you move the unit.

Instructions:
1. make a unit variable "u" and set it to the unit you want to move
2. make 2 real variables, x and y.
3. set x to the x coordinate of the point you want to move him to.
4. set y to the y coordinate of the point you want to move him to.
5. run the following two custom script actions and type exactly what I've typed (including the word "call"):

  • Custom script: call SetUnitX (udg_u, udg_x)
  • Custom script: call SetUnitY (udg_u, udg_y)
These will move the unit to the desired location and should preserve the animation.
 
Level 28
Joined
Jun 4, 2007
Messages
1,479
Would the unit variable work with array in custom script?
More specifically: [Player number of (Owner of (Picked Player))]

EDIT: That goes for the x and y aswell. Since it's a looping movement (aka slide) just about everything is based on variables with arrays.

EDIT 2: Tried it out with rough variables (not multiplayer) and the moving part worked but the animation is still beeing reset.
 
Last edited:
Level 28
Joined
Jun 4, 2007
Messages
1,479
  • Strafe Movement
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Strafers and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Strafing[(Player number of (Owner of (Picked unit)))] Equal to True
            • Then - Actions
              • Unit - Move (Picked unit) instantly to ((Position of (Picked unit)) offset by 10.00 towards (Angle from (Position of (Picked unit)) to Strafe_Target[(Player number of (Owner of (Picked unit)))]) degrees), facing (Position of Strafe_Victim[(Player number of (Owner of (Picked unit)))])
              • Set AnimationTime[(Player number of (Owner of (Picked unit)))] = (AnimationTime[(Player number of (Owner of (Picked unit)))] + 0.02)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • AnimationTime[(Player number of (Owner of (Picked unit)))] Greater than or equal to 0.82
                • Then - Actions
                  • Set AnimationTime[(Player number of (Owner of (Picked unit)))] = 0.00
                • Else - Actions
            • Else - Actions
There it is.

  • Animation - Play (Picked unit)'s walk animation skipping the first (AnimationTime[(Player number of (Owner of (Picked unit)))]) seconds
An action like this would solve the problem but it doesn't exist.
 
Level 14
Joined
Aug 30, 2004
Messages
909
You need to use those custom scripts I wrote to preserve the animation. Keep in mind that the walk animation won't work if the unit isn't walking. I'll show how to fix it...sort of.

Make a new map and delete all triggers. Then make a footman. Make a unit variable u, two point variables: tempPoint and tempPoint2, a boolean variable strafingBoolean, and two real variables x, and y. Then make these triggers:

  • start
    • Events
      • Player - Player 1 (Red) Presses the Left Arrow key
    • Conditions
    • Actions
      • Set u = Footman 0000 <gen>
      • Unit - Set Footman 0000 <gen> movement speed to 0.00
      • Set strafingBoolean = True
  • repeater
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
      • strafingBoolean Equal to True
    • Actions
      • Set tempPoint = (Position of Footman 0000 <gen>)
      • -------- change tempPoint2 to be the location that you want the unit to be facing while moving. Right now it just faces north (90 degrees). --------
      • Set tempPoint2 = (tempPoint offset by 256.00 towards 90.00 degrees)
      • Unit - Order Footman 0000 <gen> to Move To tempPoint2
      • Custom script: call RemoveLocation (udg_tempPoint)
      • Custom script: call RemoveLocation (udg_tempPoint2)
      • -------- -------- --------
      • -------- this line stores x as the x-coordinate of the footman. Do the same with y to get the y coordinate. --------
      • Custom script: set udg_x = GetUnitX(udg_u)
      • -------- this line sets the new location to be 10 points to the east. Use -10 to move west, and make changes to the y axis to move up and down. --------
      • Set x = (x + 10.00)
      • -------- this moves the footman's x-axis location to the new x --------
      • Custom script: call SetUnitX (udg_u, udg_x)
      • Wait 3.00 game-time seconds
      • Set strafingBoolean = False
Test the map and press <--.

You'll need to play around with those to get the facing of the unit correct. Also, the footman will walk forward at a semi-normal speed. The "set movement speed to 0" doesn't actually set it to zero unless you go to the Advanced tab and change the Gameplay Constants. Change the minimum speed to 0 or 1 or something and you can get a true strafing effect.

Using those JASS lines with arrays are fine. instead of typing: set udg_x = GetUnitX(udg_u) just type: set udg_x = GetUnitX(udg_u[udg_tempInteger]). Make a variable tempInteger and set it to the array position (the player number, or whatever it is...so player 7 should have tempInteger set to 7 before that trigger fires and it will move unit u[7]).


EDIT: Here it is if you want to see it working:

http://www.hiveworkshop.com/forums/pastebin_data/autivu/_files/strafe.w3x

I made a few notes in the trigger comments for you as well.


EDIT 2:

You can add this line to the first trigger:
Animation - Lock u's Chest to face u, offset by (0.00, 90.00, 90.00)

and then change the second trigger to:
  • repeater
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
      • strafingBoolean Equal to True
    • Actions
      • Set tempPoint = (Center of Region 000 <gen>)
      • Unit - Order Footman 0000 <gen> to Move To tempPoint
      • Custom script: call RemoveLocation (udg_tempPoint)
      • -------- -------- --------
      • Custom script: set udg_x = GetUnitX(udg_u)
      • Set x = (x + 10.00)
      • Custom script: call SetUnitX (udg_u, udg_x)
      • Wait 3.00 game-time seconds
      • Set strafingBoolean = False
This way the footman looks forward but walks to the side. It actually looks pretty stupid, but it might look better with your marines. At the end be sure to reset the unit's body part facing or whatever.

What it does is locks' the footman's chest toward himself offset by 90 degrees north.
 
Status
Not open for further replies.
Top