Forum rules - please read before posting.

A standard way to know if the player is playing a custom animation

edited June 2018 in Technical Q&A
Hi. I am sorry that this may be a super simple question, but I searched the forum and manual without finding the answer. I am trying to find whether there is a standard Action or script to know if the player animator is playing a custom animation. The Charstate.custom seems not for this purpose?

I am now using a Global variable to handle this, but hoping to find a "faster" way. Thank you very much.

Comments

  • It depends on a few things.  What is your player's animation engine, and how are you triggering the custom animation, exactly?  If you can post screenshots of the relevant Player Inspector / ActionList / Animator, that will help in understanding.
  • I set the animation engine to Custom, but then I didn't put the script name into the Players' inspector. Instead I attached script to the Player game object. I did this because the animation played is not only controlled by the input, but also depends on the movement speed of the Player. I don't know how to do that by overriding the IDLE() etc. functions, so I just attached the script. This works well so far.
    image

    For playing the custom animation, I always use the Object > Animate action. Because probably due to the way I control the animation by an attached script, the Character > Animation action is overtaken by the script (even if I make the animation engine change to Unity Sprite during GameState.Cutscene). That is also the reason I need to use a variable to ask the script to "make way" for the action. Thus I wish to know if there is a single line of code to tell the script that the Object > Animate action is playing.
    image

    Maybe this way is not how AC is intended to be used?
  • edited July 2018
    Checking the Object: Animate Action's Wait until finish? Action will cause it to linger until the custom animation is played.  Otherwise, you can do it with script:

    bool isFinishedCurrentAnimation = AC.KickStarter.player.GetAnimator ().GetCurrentAnimatorStateInfo (0).normalizedTime >= 1f);

    You haven't shared too much detail on why you're relying on a custom script for your animation, but you should be able to rely on "Sprites Unity Complex" animation - because animation playback then relies on Animator parameters as opposed to calling animations by name.

    Movement is then dictated by your own animator transitions - typically the "Move speed" float causing a Idle -> Walk transition.  However, you can also attach your own custom scripts to affect other parameters that also affect your animation playback.
  • I will try. I didn't use "Sprites Unity Complex" mainly because there are too many transitions that I think using a script is easier.
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.