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

Playing animations backwards

Status
Not open for further replies.
Hi everyone!

I noticed a strange thing when i was trying to play an animation backwards through triggers by doing this:

JASS:
call SetUnitTimeScale(u, -1)

The animation only plays to it's first frame, then it stops. In other words, while forwards animations loop when they reach the end, playing it backwards would have it stop on the first frame where it should loop back to the last frame.

How do you solve this? I know it is possible, since i have seen it done in Combat Zone and other maps (hell, i even checked the source code for CZ, and it seemed to be done just like this!).

Here is a snippet of how it was made in CZ:

JASS:
if MovingBackWards then
    call SetUnitTimeScale( Obj, -SquareRoot(Speed)*r )
else
    call SetUnitTimeScale( Obj, SquareRoot(Speed)*r )
endif

where "speed" is the speed squared and "r" is a real value that varies between units (can be anything between 0.1 and 0.3).

So, in short, how do you play animations backwards?
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
I cannot remember how I got it to work, but I did encounter the same problem you're encountering. I'm uncertain whether it has to do with the fact that you're passing an integer instead of a real, or if you need to play the animation after setting the timescale, or if it's a combination of the two.
 
Actually, in my system, i am using:

JASS:
call SetUnitTimeScale(.u, .speed/.class.maxspeed)

where both speed and maxspeed are reals (and speed can be below 0).

Trying to set the animation index 30 times per second only ended up ruining what was already working. I still have no suloution.


EDIT: I tool the liberty to post the entire main loop of Combat Zone (the map is unprotected) for your amusement:

http://www.hiveworkshop.com/forums/pastebin.php?id=8c0eji

Try searching for "TimeScale" and you will find the relevant code.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Try this.

My real value is -0.75.
Because if you use -1.00, it will be normal animation speed.

When humans move backward, they tend to move slower than they move forward, right ?

Therefore, I want to add the "realistic" feeling to the animation speed, when we move backward, our animation speed would be reduced by 25% (0.75) from usual animation speed.

Also, this is pretty cool discovery, I wanted to know how The_Witcher did but I don't know which function, and I can't read JASS triggers too.
But since you mentioned something about SetUnitTimeScale, I decided to experiment with it.

This gives me the idea of making movement system in GUI :p
 

Attachments

  • test13.w3x
    13.1 KB · Views: 49
I wasn't. It was something i tried once since from your post i took it you suggested it (time scale is updated in the "game loop" of my map, so setting animation afterwards would have to be done there).

@Purgeandfire: Really nice link there, at least the link inside it to pyrogasms post explaining the solution. I am still not sure how you are suppose to set it in practice though, but i will experiment some and see what happens. I do know however, that i don't want (and propably don't need) to import a whole system to solve it.
 
Level 9
Joined
Jul 10, 2011
Messages
562
you seem to missunderstood my post ^^ i posted the system so you can read the trigger (its not that long) and look how its done there. :D
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
Okay, so I decided to test it out myself.

And I am not encountering any problems with backwards walking. Trying other animations however does not work. They play, and then they just stop.

This is how I made it walk backwards:
JASS:
call SetUnitAnimationByIndex(u, 10)
call SetUnitTimeScale(u, -1.0)
I was testing with a peasant, so the index for the animation was 10. That code btw, was run only once. I had it run at mapstart, and witnessed the peasant walk backwards forever.
 
sorry defskull! i might check out your map when i get home, it's just that reading GUI feels generally unappealing to me.

As far as what you mentioned with slowing backwards animation, i think it is the wrong approach. If the animation speed is bound to the movement speed, you should obviously limit the backwards movement speed instead rather than just the visual of it. But maybe your system works in some other way.
 
Status
Not open for further replies.
Top