Forum rules - please read before posting.

Player Animation and Walk Pivoting not working correctly

edited June 2023 in Technical Q&A

Hello there!

I was following Chris' Tutorial (Adventure Creator 2D Primer) on youtube, but using my own graphics.
I have two issues:

1) The player's talking and walking animations don't play (Only idle animation works).
2) The Player sprites seem to be pivoted on the top, whereas I set all the sprite pivot points to bottom before import.

I would like to know how to fix that.

This is a recording of the issue: The chicken walk and talk animation are not working, and when walking it walks below the nav mesh, as if the pivoting point was on the top right instead of on the bottom:

So here I try to summarize the entire related setup of my game:
Before creating the animations in Unity, I set each sprite's pivoting orientation to bottom:

This is the animation setup for my player:

I create all three animations with the correct name:

They are included in the animation controller:

The animation preview works just fine for all animations in the Animation window for the Player sprite:

I have set the 2D Start Marker Point position way up high above the desired starting position, which indicates that the position pivoting point is 'top' instead of 'bottom'.

Even though I set the nav mesh at the correct position, the chicken walks far below, indicating again that the position pivoting point is 'top' instead of 'bottom'.

Changing the sprite sort point did not change anything (I tried setting it to 'Pivot', which didn't change anything so I set it back to 'Center'):

Even though the issue does not stem from there, here is my dialogue setup, just in case:

This is how I call player speech inside the action script:

What do I need to do to fix this?

Comments

  • Welcome to the community, @LionBoxDev.

    It is a pivot issue - but not of the sprite asset. Instead, it's to do with the position of your character's "Sprite child" object - named "Chicken sprite" in your Hierarchy.

    This object has a local Position of (-2.69, 4.86, 0), whearas it'll need to be (0,0,0) - so that it's got the same position as its parent object. AC should warn you about this in the Console at runtime.

    Clearing the "Chicken sprite" object's position values should clear it all up. You'll also need to adjust your PlayerStart position - as this had to be moved into the wrong position to compensate for the sprite's offset.

  • edited June 2023

    Hello @ChrisIceBox ,
    thank you for the welcome, and the fast reply!

    Yes, that was the offset issue, I must have accidentally moved the sprite instead of the player object! Thanks!

    For the animations, I get an error message in the console for each animation:

    The log tracker reads:

    -> AC debug logger
    UnityEngine.Debug:LogWarning (object,UnityEngine.Object)
    AC.ACDebug:LogWarning (object,UnityEngine.Object) (at Assets/AdventureCreator/Scripts/Static/ACDebug.cs:33)
    AC.AnimEngine_SpritesUnity:PlayCharAnim (string,int) (at Assets/AdventureCreator/Scripts/Animation/AnimEngine_SpritesUnity.cs:1012)
    AC.AnimEngine_SpritesUnity:PlayStandardAnim (string,bool) (at Assets/AdventureCreator/Scripts/Animation/AnimEngine_SpritesUnity.cs:960)
    AC.AnimEngine_SpritesUnity:PlayIdle () (at Assets/AdventureCreator/Scripts/Animation/AnimEngine_SpritesUnity.cs:814)
    AC.Char:AnimUpdate () (at Assets/AdventureCreator/Scripts/Character/Char.cs:1087)
    AC.Char:BaseUpdate () (at Assets/AdventureCreator/Scripts/Character/Char.cs:671)
    AC.Player:_Update () (at Assets/AdventureCreator/Scripts/Character/Player.cs:191)
    AC.StateHandler:Update () (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:273)

    A fairly similar log gets tracked for the talk animation for example:

    -> AC debug logger
    UnityEngine.Debug:LogWarning (object,UnityEngine.Object)
    AC.ACDebug:LogWarning (object,UnityEngine.Object) (at Assets/AdventureCreator/Scripts/Static/ACDebug.cs:33)
    AC.AnimEngine_SpritesUnity:PlayCharAnim (string,int) (at Assets/AdventureCreator/Scripts/Animation/AnimEngine_SpritesUnity.cs:1012)
    AC.AnimEngine_SpritesUnity:PlayStandardAnim (string,bool) (at Assets/AdventureCreator/Scripts/Animation/AnimEngine_SpritesUnity.cs:960)
    AC.AnimEngine_SpritesUnity:PlayTalk () (at Assets/AdventureCreator/Scripts/Animation/AnimEngine_SpritesUnity.cs:856)
    AC.Char:AnimUpdate () (at Assets/AdventureCreator/Scripts/Character/Char.cs:1083)
    AC.Char:BaseUpdate () (at Assets/AdventureCreator/Scripts/Character/Char.cs:671)
    AC.Player:_Update () (at Assets/AdventureCreator/Scripts/Character/Player.cs:191)
    AC.StateHandler:Update () (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:273)

    Could this be related to the fact that I changed the Chicken sprite's name inside the project tree from the original sprite name to 'Chicken Sprite'?

    When I go into the 'Chicken Sprite' object's animator, I can play every animation:

  • It's to do with the state names in your Animator.

    When a 2D character automatically plays back animations, such as ChickenIdle_L, it'll look search the Animator Controller for a state with the correct name.

    This isn't necessarily the name of your AnimationClip asset. Your animation assets are named properly, but their states in the Animator are different - you have them named as "Chicken Idle", "Chicken Walk" "Chicken Talk".

    Rename these states to ChickenIdle_L, ChickenWalk_L and ChickenTalk_L respectively, and they should then play.

  • Yes that was it!
    I imported the animation assets into the Animation Controller, before renaming them. And I assumed the Animation Controller will update itself automatically when any changes happen, but it doesn't!

    Thank you very much for your quick and precise help!
    Lion

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.