is it possible to reverse an animation in the editor? (with animation player)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ababen

i know there’s the play backward method, but i want to reverse the animation and save it, not just play in backwards by calling a method. is that possible?

:bust_in_silhouette: Reply From: DaddyMonster

Yup. The best way to handle animations is to make an AnimationTree. You can then go ahead and make a node setup. Personally I do the node setup like this:

animation -> TimeScale -> Seek -> Output

If you have more than one animation then you can add a Blend2 and flick between them. I recommend adding a script to the AnimationTree with methods calling these nodes so it’s all nicely self contained. To send the animation backwards you just need to set the TimeScale to -1 and it will run backwards. The seek is there for convenience to handily reset the animation to the start by entering 0 and otherwise defaults to -1/false not interfering.

See the docs for a full explanation on how to call the nodes. It’s very straightforward.

Hope that helps.

EDIT: Oh, hold on you said you don’t want to call a reverse method… I don’t get the “why” of this at all but ok. Then, what can I say? Make an animation in reverse. But you still need a method to call that… Honestly, I’m baffled why calling a reverse method isn’t good for you. How can you run an animation without calling a method? I’m confused. Anyway there’s no way to flip an animation that I know of other than duplicating it and swapping the keys.

this was helpful, thank you:)

ababen | 2021-06-11 19:20

How can I make TimeScale -1 in AnimationTree? It seems to be not allowed…

VanDeiMin | 2021-12-21 18:37

Yeah, it’s a limitation in the editor which I hope they address. You can set it to -1 in code.

DaddyMonster | 2021-12-21 19:08

Thank You for reply.
I know i’m not programming eagle and almost for sure i’m making mistake.
For now it seems that if I put code: "anim_tree.set(“parameters/BlendTree/TimeScale/scale”, -1.0) "
only what it can do is to set TimeScale to 0.0.
i even tried do something like that:

tool
extends AnimationTree

func _process(delta: float) → void:
set(“parameters/BlendTree/TimeScale/scale”, -1.0)

same result. printing “get(“parameters/BlendTree/TimeScale/scale”)” shows ‘-1’, but
BlendTree node on AnimationTree shows 0 and behaves accordingly.

I begin to think AnimationTree is too advanced to do so trivial thing like play one animation backwards and at the end play second backwards .

VanDeiMin | 2021-12-22 02:56

Sorry to take so long to reply, xmas needs a surprising amount of tidying! :wink:

Ok, you were soooooo close! What’s that old quote? “Computers are like old testament gods, all rules and no mercy!” You don’t put “BlendTree” is all. I can see why you would think that.

Here’s some code I know is working cut straight out of my main project to get you on the right lines:

func _on_AirshipDoorsOpenTimer_timeout():
	is_airship_door_open = not is_airship_door_open
	reset_blends()
	set("parameters/AmphAirshipBlend/blend_amount", 1)
	set("parameters/AirshipLaunchTimeScale/scale", -1)

I like to put the animation code in AnimationTree but that’s not essential obviously. Hope it helps.

Good luck and merry xmas!

DaddyMonster | 2021-12-22 20:59

Thank You Sir.
Merry Christmas and Good Luck for You too!

VanDeiMin | 2021-12-23 01:34