Forum rules - please read before posting.

Movement Animation in 2D

edited May 2014 in Technical Q&A
OK, this might be really straight-forward so apologies in advance...

I'm having problems with the animation of my player character in a 2D game (using Unity's native 2D). I've set up the animation controller however the animation appears stuck...

I think this is to do with the transitions between animations, the Unity examples change or run animations based on simple input or direction to handle the transitions. Ingame the player while walk along the navmesh to the point clicked... So I guess what I'm asking is how do II set it up to detect which direction the player is moving and play the appropriate animation, reverting to idle after they have moved? 

Note- I may also be completely wrong in my above reasoning so if anyone has any pointers feel free, I tried to reverse engineer the Brain2D player but I couldn't seem to get my head round it...

Comments

  • Hi Maramas,
    Am I correct in assuming that you want your character to behave like Brain2D? If so, check this tutorial out: http://www.iceboxstudios.co.uk/adventure-creator/tutorials/making-unity-sprite-based-character-2d
  • Guran, thanks... I'll have another go over it and see if I'm just being a bit derpy....
  • Good luck! Remember that it's important to save the animation clips with extensions _D for down, _U for up and so on.
  • Yep, went back over this and I'm having the same issue, no animations play and the console throws a GotoState not found error... 

    Animator.GotoState: State could not be found
    UnityEngine.Animator:Play(String, Int32)
    AnimEngine_SpritesUnity:PlayStandardAnim(String, Boolean) (at Assets/AdventureCreator/Scripts/Animation/AnimEngine_SpritesUnity.cs:581)
    AnimEngine_SpritesUnity:PlayIdle() (at Assets/AdventureCreator/Scripts/Animation/AnimEngine_SpritesUnity.cs:528)
    AC.Char:AnimUpdate() (at Assets/AdventureCreator/Scripts/Character/Char.cs:358)
    AC.Char:FixedUpdate() (at Assets/AdventureCreator/Scripts/Character/Char.cs:198)
    AC.Player:FixedUpdate() (at Assets/AdventureCreator/Scripts/Character/Player.cs:76)


    I followed the tutorial step by step so I'm pretty sure I've not missed anything other than that I'm not using Up or Down animations... do I need to disable them? 
  • If you have "Multiple directions" checked, AC will expect all four directions present.

    However, you may want to consider using Sprites Unity Complex for this (as the Player's animation engine setting).  This setting will basically let you create your own Mecanim FSM to suit your own needs.  The character's direction will be passed to the FSM as an integer parameter, which you can choose to ignore or use however you wish.

    Please refer to the manual for more on using the "Sprite Unity Complex" animation engine.
  • edited May 2014
    Thanks Chris, in the end I fixed it by adding in the Idle_U etc animations and having them contain a blank frame... pretty dirty work around but it is fixed...

    It does however bring me to the next problem that I can't find any info on... The game I'm making is pure 2D and as such the NavMesh is currently a poly squashed down to form a line... 

    This causes issues as it's not perfectly straight... and for some reason the player markers seem to go a bit haywire causing the player to walk around & along the NavMesh prior to stopping somewhere normally away from where the marker is placed.... any ideas? ? 
  • I'm also curious about this, in addition to whether there's an easy way of restricting Direct Control to the X-axis
  • Seems like it ought to be more simple than it is, but unfortunately that's just how these things go sometimes!  Which pathfinding method are you using?  Try using Unity Navigation, and - once you've baked your NavMesh, create a new segment that sits "upright" so that it can catch the cursor clicks.  It may take a bit tweaking to get right, so see how you go.

    @DieHappyGames: You can use the Player: Constrain Action to limit motion to just left and right, which will be the x-axis provided your Camera is looking side-on.


  • Thanks Chris, I'm using the polygon collider for pathfinding and the NavMesh 2D option from the settings option... It's not a major issue as I can work around it...altho it does leave the scene looking a tad messy... way points in the sky etc...
  • If you're using the Polygon Collider method, another such Collider upright should do it.  It may be messy to look at, but the important thing is it works, at least!  Bear in mind that you need not cover the whole sky - the point-and-click algorithm will automatically "search down-screen" if you don't click directly onto a NavMesh collider.  See the Demo game - you can click on the wally and Tin Pot will still move around.
  • Hi,
     Im having troubles with 2D animation of my character (im following "Brian" tutorial), all seems ok but some of animations wont play (every time few diferent ones are not working). Im using Sprites Unity
    Multiple Directions is checked and Diagonal Sprites as well, there are properly named animations in Animator...
    What is wrong ??
    In the console there is:
    Cannot play animation clip PlayerWalk_D on Player
    (or diferent one dtat is not working).
    Some of animations always work ex U,L, DR, (but rest is not...)

    Should I use Sprites Unity Complex ? (is this base engine messed up?)
    Brian in demo works just fine when im running demo...


    imageimage

  • edited June 2016
    Im using Unity Personal v 5.3.4f1 64 bit
    Adventure Creator v 1.51
  • Okay dont mind that I had spelling errors in half of animations...
    :D
    sorry for spaming ;]

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.