Forum rules - please read before posting.

Detecting an inventory interaction and delaying it until an anim completes

Hi
I have a situation where I need to detect whether an inventory interaction occurs with a given inventory item, and then run an animation before the interaction occurs. This will need to delay the interaction until the anim runs, or cancel it, run the anim, then retrigger the interaction.

This needs to happen with each use of the item. I could do this via an actionlist, but I feel it's prone to user-error when creating the nodes each time so I would prefer to code it in once.

I can see I can use OnInventoryInteraction, which gives an InvItem object. Looking at it, I could use the following workflow...

1) Grab the AssetList from the InvItem object as a reference
2) Use KillAllInstances of that actionlist (not sure but I doubt there will be more than one of those actionlists running at once)
3) Run the animation as required.
4) Once the anim has finished then I could Interact with the AssetList to run it again.

Does that work roughly? Is there another (more straightforward ) way to do it that I don't know of?

Olly

Comments

  • Or what about inserting via code two new action nodes to any actionlist that uses a certain inventory item. First node would be to trigger the anim, second would be to wai 3 seconds for the anim to complete. Then I could run the newly edited action list.

    Any other methods?

  • At the moment I've got this. It works, but the actionlist doesn't seem to stop. It carries on running, whilst the other code is actioned, then runs again at the end with the Interact() line.

                ActionList tempActionList = button.interaction;
                tempActionList.Kill();
                GlobalVariables.SetBooleanValue(GlobalVariables.GetVariable(droneTriggerVariable).id, true);
    
                // Scale the player to the current scale as a quick and dirty timer
                followPointGO.transform.DOScale(followPointGO.transform.localScale, 6f).OnComplete(()=> 
                {
    
                    prepDroneToFly(destinationGO);
                    //KickStarter.actionListManager.Resume(tempActionList, true); 
                    tempActionList.Interact();
    
                });
    
  • Try using ResetList instead of Kill, but you can also try Pause to later resume it.

    You might find, however, that the cleanest way is to embed the behaviour at the start of your Interaction. Killing an ActionList as soon as it runs may have different behaviour depending on what Actions are at the front - some Actions run instantly, while some run over time.

    You don't need to create your animation Actions for each Interaction: move them to an ActionList asset, and then reference it at the start of the Interaction with an ActionList: Run Action. Checking Wait until finish? here will cause it to delay the Actions that follow.

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.