Forum rules - please read before posting.

Start animation after an action

Hello again,

I don't figure out at all how to do this, which is why I asked this question and maybe even it holds more about Unity, but I said I'll try anyway :)

After pressing a button (not character, the player person), in one scene to start an animation (like a short clip, which I already have), then to end and enter another scene? All this using AC.

I used a sprite animation, which starts when I start the scene. In the action list, when you click on the hotspot, i have Object: Animate, Clip: (my animation). I don't quite understand what the rest of the options are, at Object for example, I can't attach my Hierarchy sprite. And it doesn't work that way.
So, in short, how do I start the animation when I interact (without a character in the game)?

~And another question, that we are still on this subject, not to open another topic, can I interact with the Animator and AC? For example, when the Animator animation ends, set a boolean parameter (for example) to true. The same parameter should be used by the AC, so that when set to true, it starts a Narration (as a subtitle). Can those parameters be used by AC and Animator at the same time? I ask this for better synchronization, not to start writing without display. Or if there is another better option :)

Sorry if I didn't explain exactly how it works.
Thank you!

Comments

  • I think I follow, but as this is a visual issue it may be best to share some screenshots to clarify.

    The Object: Animate Action can be used to animate objects, but you need to specify which "Animation engine" to make use of. This will affect what type of object you then assign below - but it depends on how exactly your Animator is set up.

    The object you want to animate (the sprite you mention) will need to have an Animator component attached that includes the animations already created within its Animator Controller.

    If you're new to Unity, check out Unity's docs on this topic here:
    https://docs.unity3d.com/Manual/class-AnimatorController.html

    Once that's set up, you can use the Action to control animation playback. For sprite animation, you'll typically want to set the "Animation engine" to Sprites Unity Complex, as this gives you more flexibility. You can then assign the sprite's Animator into the Action.

    You'll then get a Method field that you can use to control exactly how the animation is changed:

    Change Parameter Value - this means you can use the Action to change an Animator Parameter in your Controller (e.g. a Bool from False to True), which, when used in Transitions in your Controller, can cause a new animation to play. However, since AC can't predict what effect this will actually have, you'll have to follow this Action with an Engine: Wait Action to wait the length of the animation if you want to wait until doing anything else.

    Play Custom - this allows you to enter in the actual name of the Animation clip you want to play (provided it's present in the Animator Controller), and have AC play it manually. This method has the added bonus of including a Wait until finish? option, since AC knows what animation it is you're actually trying to play.

    If you want to sync up your animation with other animations or sound, etc, also know that Timeline is an option. You can control the playback of Timeline assets using AC's Engine: Control Timeline Action.

    As for reading Animator parameter values, it'd be possible to attach a Variables component to your sprite / animator object, create a new Variable of the same type (e.g. bool), and then also attach a simple custom script that transfers the parameter value to the Variable each frame, i.e.:

    using UnityEngine;
    using AC;
    
    public class VariableTimers : MonoBehaviour
    {
    
        private Animator _animator;
        private Variables variables;
        public string boolName = "MyBool";
    
        void Awake ()
        {
            _animator = GetComponent <Animator>();
            variables = GetComponent <Variables>();
        }
    
        void Update ()
        {
            variables.GetVariable (boolName).BooleanValue = _animator.GetBool (boolName);
        }
    
    }
    

    Where "MyBool" is replaced with the name of both your bool parameter and bool variable.

  • That was the answer I wanted to see. I didn't understand exactly how to make the connection between animations and AC, but now I understand. Thanks again for everything :)

  • No problem - actually, I've posted a generic script to handle Bool, Int, and Float types up over on the AC wiki here: https://adventure-creator.fandom.com/wiki/Link_an_Animator_parameter_to_a_Variable

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.