Forum rules - please read before posting.

Run Action List after Animation

Hi again all. I've re-started my project after nearly 12 months off, I've searched around and can't find an answer so thought it best to ask it here.

I have a trigger cube that when a character enters it a bool in the animation is changed to true (then obviously false when they leave the space). I then have another animation bool that changes when a certain object is clicked on, when both of these aforementioned bool's are true then a certain animation will play (both have to be true at the same time).

My issue is that I need to know when both of these animation bools are true - at the moment the only way that the game knows if they are both true is within the animator controller (hence why it is able to play the specific animation required) however how do I get to know this information outside of the controller so that I can do more than just play a specific animation?

I was initially looking at trying to run an action list when the animation plays (and that action list would then either run the proceeding actions that I need it to, or simply change a local variable so that I can access that info to do more than just run one action list). I am struggling to find this ability, I was hoping within the animation controller it would be as simple as selecting the specific animation and then clicking on an option to run an action list (so when both bool's are ture the controller will go to the specific animation state and not only play the animation but also run a specific action list). Any ideas or help with this at all? Thanks in advance (and hopefully I've explained myself well enough).

Mike.

Comments

  • Welcome back, Mike.  There are a number of ways you can do this:
    1. Use Animation Events to trigger an ActionList.  As you were hoping, you can select an Animation in Unity's Animation window and have an Animation Event run an ActionList asset file.  An ActionList asset can be run by simply triggering it's Interact() method.
    2. Use AC Boolean variables to keep track of the Animator boolean variables by creating two of them and setting them to the same values at the same time, e.g. the Trigger controls both the Animator variable, and the AC Boolean variable.  You can then check this value using the Variable: Check Action.
    3. Use a custom script that reads your Player's Animator boolean parameters directly, e.g:
    AC.KickStarter.player.GetAnimator ().GetBool ("Parameter1");

    Such code could be placed in a custom Action that runs as part of the Triggers.
  • Chris, once again thanks for the fast and helpful response.

    The first option is not ideal because I only want this event to happen in this specific scene (so if I use the animation in other scenes then it will try to call this event each time - from what I understand). Also two different characters use the same animation and so when the animation plays I'd need to know which character played it. However I was not aware that this option was even possible so even though I won't be using it I'm very grateful for the advice since I'm certain it will come in handy at some point later in my project!

    Option 2 is ideal however I'm struggling how to do this, are you advising that I make the trigger change the animator bool as well as AC variable bool upon enter (and then change them both back on exit)? I can understand this however for my situation it would not work. Similar to my explanation for option 1 I need to know which character has entered the trigger volume (hence why the trigger changes the animator of the specific characters who's collider enters the volume - a fantastic ability of your plugin by the way - however if I am asking the trigger to also update an AC variable then I won't be able to differentiate between which character triggered the area and therefore I wouldn't be able to tell the engine which AC variable to update, so whether it is the local variable for CharacterA or CharacterB).

    Again I do hope that I have explained myself well enough, if I have misunderstood your advice for point 2 though then please let me know.

    In the meantime I think I will proceed with option 3, despite my very limited ability to script, whereby I will look to write a custom script where each character has their own local boolean in AC and I will update that value via the custom script so that this characters AC bool will show as true only when their animator bool is true as well as the main local variable bool is true also. I can then, as you advised, use the Variable: Check Action at any time to check what I need to check.

    If I've made this too complicated then please let me know, despite my very limited scripting knowledge/ability I do like to jump at the chance of writing scripts where easy enough to do so as it does give me a big sense of accomplishment so I'll let you know if I'm successful or not. Thanks again Chris.

    Mike.
  • All sorted now thanks to your advice Chris, took me longer than I'd have liked however happy that I managed to sort it! Apologies in advance as I have a new query (going to search again first so might not need to post it) however just a heads up that I'll likely be asking another question again later!
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.