Forum rules - please read before posting.

Hold off Hotspot Interaction until ActionListAsset is run OnHotspotReach?

edited May 2023 in Technical Q&A

[Unity 2021.3.25f1 - AC v1.77.3]

Hi Chris!

I'm probably stumbling on something very silly but, under a given condition ("IsFlying" == true) I wanted to run an ActionListAsset when my Player reaches an Hotspot, and only after such ActionListAsset is over I want the game to run the actual Hotspot Interaction.

This is the code I use to run the ActionListAsset:

private void EventManager_OnHotspotReach(Hotspot hotspot, Button button)
{
    // ...

    if (AC.GlobalVariables.GetVariable("IsFlying").BooleanValue)
    {
        AL_StopFlying.GetParameter(0).intValue = 1;
        AL_StopFlying.Interact();
    }

    // ...
}

Right now what happens is that they both run at the same time.

In the above screenshot:

  • Illy_Mecanim is the above-mentioned ActionListAsset
  • Hotspot 2D: X is the Hotspot's Interaction. Its Player action is set to Walk to.

My ActionList settings are the following:

Is there something I'm missing?

Thanks a lot, as always!

Comments

  • Your screenshots aren't showing for me - but what you're getting is the correct behaviour. There's no logic telling the Interaction to wait until the injected ActionList has begun running.

    One way to do this would be through script, where the OnHotspotReach recording the ActionList of the Interaction itself (button.interaction), unsetting it, and then running it manually after once AL_StopFlying has completed (via the OnEndActionList event).

    A potentially simpler way: start your Interaction with an ActionList: Check running Action that checks if AL_StopFlying is currently running, and loop in on itself if so.

  • edited May 2023

    Ah, apologies for the screenshots, but you got it nonetheless.

    I was attempting the same thing yesterday (caching the Interaction, unsetting it by "nulling" it, then assigning it again and running it after) but wasn't very satisfied about the outcome. I initially thought it was running to early for reason related to my code.

    After your suggestion I tried again, but using a WalkTo Marker \ setting a minimum distance, rather than just the WalkTo and I think I like it better! I hope that's it!

    Thank you Chris!

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.