Forum rules - please read before posting.

"Incoherent" animation pausing behaviour during Cutscenes

edited March 2022 in Technical Q&A

[Unity 2019.4.36f1 - AC v1.75.0 - Player AnimEngine: Sprites Unity Complex]

EDIT: I found a possible solution (but feedback is appreciated) and posted it in the follow-up post to this thread!

Hi!

The setup

My character has a "base" sprite (referenced to in the Sprite child field in the Player script) and different "garment" sibling sprites layered over it, all of which have separate Animators.

The Animator on the "base" sprite can be triggered easily with a Character: Animate Action, while, for syncing reasons I need to send out an Object: Send string message Action that triggers an event on an OutfitManager, that eventually simply passes the "garments" the information about which Animator State to switch to, and run it.

So, whenever I have to run a "special case" animation, this is what I usually do in my ActionLists:

Node 3: sends a message to the Player GameObject, that has an OutfitManager script that "listens" for it and triggers an event that causes all the "garment" Animators to switch their State to the provided one.

Node 4: tells the "base" sprite to switch its State to the provided one (sidenote: using Play Custom makes it sync properly with the "garments", using Change Parameter Value to the specific Animator Trigger doesn't work at all times).

The order is important because I can't wait until Node 3 has finished but, since all Animations have the same number of frames, I can just make use of Node 4's ability to do so.

The issue

I have Cutscenes where I play chains of animations (e.g. [1] pick something up [2] put it down) and what I'm experiencing is that, once the Cutscene has started, the first time I pause the game, the engine simply resets both the "garments" and the "base" Animators to their Idle states. All the subsequent times I pause the game it seems to behave as it should, by pausing the animations and resuming them once I resume the game.

I'm not sure where else to look into. Things I tried:

  • Splitting the Cutscene in multiple Cutscenes, all unskippable and game-pausing
  • Putting everything into a single Cutscene, both unskippable and game-pausing and running in the background
  • Moving some nodes around a bit,
  • Attempted adding an Engine: Wait Action after starting the animation, avoiding using the Wait until finish?
  • Checking whether my implementation of the New Input System + the possibility to switch between Direct movement and Point and Click didn't interfere with the animations (and apparently it doesn't)

Am I doing something wrong? I'll keep on investigating but, that said, if I have left something out of my explanation please let me know!

In the meantime, and as always, thank you so much in advance.

Comments

  • edited March 2022

    Writing an additional post to make it stand out more.

    Indeed the issue is in my implementation!

    I realized that the script I wrote to switch between Walk \ Run \ Idle states for "garments" keeps running in the background during Cutscenes.

    The reason being that if I did stop while AC.KickStarter.stateHandler.IsInCutscene() is true, it would set the character's Animator state to Idle also while walking towards an Hotspot.

    So, I'm investigating further! And, this time, if I find an actual solution, I'd be sure to just update this post :)

    EDIT:

    So, I know that there's a OnHostpotStopMovingTo event, but there seem not to be a OnHotspotStartMovingTo? I know there's also a Player.IsMovingToHotspot() method, but it's protected so I can't really access it publicly.

    A solution is to write something like this:

    if ((AC.KickStarter.stateHandler.IsInCutscene() && AC.KickStarter.playerInteraction.GetHotspotMovingTo() == null) || AC.KickStarter.stateHandler.IsPaused()) return;
    

    Except, I'm not sure about how "performant" it is to have a null check in an Update function?

  • And here comes the third post!
    I eventually found out that I can use AC.PlayerInteraction.InPreInteractionCutscene !

  • edited March 2022

    I know that there's a OnHostpotStopMovingTo event, but there seem not to be a OnHotspotStartMovingTo?

    The OnHotspotInteract event is triggered at the time the Player clicks, and before the Player begins moving to the Hotspot - you can read its Button parameter's playerAction value to determine if the interaction involves moving towards the Hotspot first:

    private void OnHotspotInteract (Hotspot hotspot, AC.Button button)
    {
        if (button != null && button.playerAction != PlayerAction.DoNothing)
        {
            //
        }
    }
    

    On the core issue of syncing animations: if you have to rely on multiple Animators rather than sub-layers of a single Animator, Timeline may be an alternative option as it allows you to sequence multiple animations together. I'm not sure of the exact needs of your situation, though.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.