KybernetikGames / animancer

Documentation for the Animancer Unity Plugin.
63 stars 8 forks source link

ClipTransitionSequence Preview only playing first clip + custom preview #325

Closed Pateriack closed 7 months ago

Pateriack commented 7 months ago

When I try to use the transition preview feature with ClipTransitionSequences, it only plays the first clip.

Am I doing something wrong?

For context, I am working on a souls-like game. I have a move system where I can define a "move" using scriptable objects. I am not currently using ClipTransitions, just regular old animation clips. I am using Animancer events, and I define the timing for them with a custom data structure and drawer... It's pretty clunky. As I start to work on enemy characters, I realize that I would like for them to be able to have moves which are "combos" of attack animations sequenced together.

I need to be able to preview and tweak sequences of clips, and I would love to be able to add my events in there for things like hitbox enabling and disabling, triggering stamina consumption, enabling weapon trail VFX, etc.

Is the current "Transition Preview" a good tool for this job?

How doable would it be to create a custom ClipTransition type and corresponding Transition Preview? I would love to be able to hook into the events like enabling and disabling hitboxes so I could draw them in the preview to make it easy to create and tweak new moves.

Thanks in advance! I am loving working with Animancer thus far :)

KybernetikGames commented 7 months ago

Unfortunately, a ClipTransitionSequence is just a bunch of ClipTransitions connected together by events and the Transition Preview Window intentionally disables events because they very often interact with things that aren't expecting to be controlled during Edit Mode so allowing them would lead to tons of errors. I might eventually add a way to indicate that specific events should be triggered in previews, but I don't currently have that planned.

In most games with combos, you would only perform the next attack in a combo if the player presses the attack button again for each one so a ClipTransitionSequence that automatically plays the next animation wouldn't be ideal for that anyway. In my Platformer Game Kit I just use an array of attack transitions to achieve that.

Those AttackTransitions also implement ITransitionGUI as shown here in order to draw and edit their hit boxes in the Transition Preview Window as well as drawing them over the event timeline in the Inspector.

Pateriack commented 7 months ago

Thank you for your answer.

I did some digging into the Transition Preview Window code and I think I can modify it for my purposes if I need to. It would be nice if it could handle ClipTransitionSequences in the preview, although I understand disabling the events. That seems like a sane thing to do.

I have a combo system working for my player character already, but I intend to make my enemy characters use preset combos. I'm hoping to build a nice editor since I anticipate creating and tweaking quite a few of these.

I've essentially built my own version of a transition, without actually using transitions. I'm sure your implementation is more robust and the ITransitionGUI seems likes a nice touch. I'll check that out for sure!

Edit: I took a look at the custom ITransitionGUI example and that looks like what I'm looking for. I'm sold on refactoring my system to use transitions.