Forum rules - please read before posting.

Animator.GotoState: State could not be found

Hi guys.

Building out my game and seem to be running into a problem. After building all my animations and loading them into my controller, when I test I get a ton of errors when moving downwards and upwards. The animation plays fine but the following errors prop up.

Animator.GotoState: State could not be found ; UnityEngine.ANimator:play (string, int32)
Any help? I am a n00b still :P

Comments

  • Hi,

    Is this only for moving up and down? rest are there ? i.e. left right are ok?

    This error message sounds like the animation is not there for some reason. Which can be a few things, most of which are unity issues. Annoying I know.

    Try looking at these:

    a) make sure there is indeed an up and down animation. click sprite. Then animation window -> drop down list.
    b) make sure everything is spelt correctly.
    c) Still not working : try recreating the animations for these directions. Delete and redo.
    d) look inside the animator that is attached to the sprite - select game object, double click the animator, and see what animations are in there - maybe you have multiple up's /down's.
    e) Still no joy: remove the animator and create a new one, and drag all the animations in again.

    I take that you have sprites with multiple directions yeah?

    That's all i can think of off the top of my head. Maybe someone else can think of a few more things.

    Hope one of these helps and is the issue.

    Cheers
  • HI Klarax will give it a bash after work today, thanks so much for the help.
    As for your question it is only for up and down yes, however when I walk up and down those animations play fine but the errors roll in like mad.

    I am using sprites with multiple directions yeah (up, down, left, right)

    I will go through all your steps tonight and see what comes of it. Thank you so much for the tips!

    Graeme
  • Just a bump on this, Klarax did his best to help me but unfortunately it did not solve my problem :(
  • You'll need to post screenshots of exactly what you've got, in that case.  Sorry you're having trouble, but as it's specific to your game it's all in the details.  The more you can show of your problem, the faster we can get it solved for you.
  • edited August 2015
    Hi Chris, will do that now and get back to you @Chris amazing tool you have created btw!
  • @Chris I loaded up a video and links but it seems to have been blocked
  • You can't paste the raw links in the thread?  Screenshots should be enough if you can't get a video up.
  • edited September 2015
    Here is my video on youtube It's a crap video
    And some screenshots

    Thanks again for the help.
  • No problem - if you're using Sprites Unity as your animation engine, you'll need to supply both Idle and Walk animations in either 4 directions, or 8 (depending on whether or not you're using diagonals).

    Even if you don't have a down Idle animation, you still need to have a clip in your Mecanim controller named "Idle_D" (this can just be the e.g. Left Walk animation duplicated and re-named.  Same goes for Idle_U.

    However, this is not necessary if you instead switch to Sprites Unity Complex as your animation engine.  With this mode, you instead control your animation using Mecanim parameters: you supply a walk speed, movement direction etc, and AC will control them and nothing else - allowing you to use them however you like, with no restriction on how many / few animations you want.  For more on this mode, see section 3.9 of the Manual.
  • AH magic, thanks so much Chris! For now going to use Sprites Unity and supply IDLE states for each diagonal think that will be best for now.


  • Hi Chris, another question. When I have an NPC in my scene, that npc does not need to have a walk or diag. direction animation. When I load my game I get the same error as above from that char. How do I stop the errors coming if I only want my NPC to have an idle or talk animation? most wont walk around the game but be idle and talk with the main player.

    Ideas?
  • Are you still using Sprites Unity?  It should just be a case of clearing the contents of the "Walk anim" text box in the NPC's Inspector.

    On another note, v1.49 will be more descriptive with the error: finally, it'll be able to tell you what animation it's looking for.
  • edited October 2015
    They were all blank except for the idle animation slot, I removed that, the idle state still plays and the errors are gone.

    Good to know the new update will include such cool stuff, you are working really hard on this tool so bravo to you.

    I have question need to pick your brain. I am planning to have a few NPC chars in various scenes, currently my one NPC has a total of 250 frames in his idle state. My programmer brain is telling me that's not such a good idea as its more stuff to load into memory and what happens when I add in more NPC's to the scene?

    Is there a recommended resolution one should use for an NPC when bringing in multiple frames (aiming for 1080P as my highest res)?
    does a sprite sheet work better or is it OK to import each frame?

    I have a total of 3 scenes now, 1 NPC and the player. I see its chomping a lot of memory and when running in unity it runs slow in the start.

    Thoughts on this would be cool to hear. 

    Lastly thought of it as an option, would be cool to have a set of checkboxes in the NPC script to select what animation states you will have so that you don't need to design stuff for all the directions... probably a mission to code but that could rid of a lot of errors :P
  • Your question of resolutions / frame counts I can't answer, I'm afraid.  That's more of a general usage of Unity, so I'd recommend asking on the official Unity forums.

    Regarding the other issue, the "Sprites Unity Complex" option was created for exactly that purpose.  It allows you to animate your characters however you like - whether it be more complex, or more simple, than Sprites Unity is built for.
  • Cool thanks Chris, will dig a little deeper :)
  • edited October 2015
    [wrote stuff - then read the comments more clearly. so deleting due to chris stating the animator needs all directions]
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.