Forum rules - please read before posting.

Run a character animation from script.

edited May 2018 in Engine development
Hello,
I'm using Animation engine for my character : Sprites Unity
What I'm trying to do is to trigger an animation from script using the Animate Action.

I do the following

actionCharAnim = ScriptableObject.CreateInstance<ActionCharAnim>();
actionCharAnim.isPlayer = true;
actionCharAnim.method = ActionCharAnim.AnimMethodChar.PlayCustom;
actionCharAnim.clip2D = "MyAnimationName";
actionCharAnim.willWait = true;
actionCharAnim.Run();

But this on execution gives me an error : Could not create animation engine!

What Am I missing?

Thank you!


p.s. sorry I accidentally posted it on wrong forum...








Comments

  • An Action without an ActionList won't work as you intend - the "willWait" bool will have no effect, for one thing.

    To avoid the error, replace:
    actionCharAnim.isPlayer = true;

    with:
    actionCharAnim.animChar = KickStarter.player;

    To be able to make use of "willWait", you should instead just make an ActionList asset with the Action as normal, and then call it via script:

    myActionListAsset.Interact ();
  • Ok! that worked!
    So I create an actionList seting up the action as I wish and run it through script with interact..
    Thank you very much
  • @ChrisIceBox ;Following this post I have this strange issue.. When I run an Actionlist with object: animate using myActionListAsset.Interact (); , all the menus configured as appear type : during gameplay are hidden... any idea what happens?
  • If the ActionList is set to block gameplay, then gameplay menus will hide while it runs.

    You can prevent an ActionList asset from blocking gameplay by changing its When running field to Run In Background.
  • Perfect! Thank you very much!
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.