Forum rules - please read before posting.

Sprite root keeps rotating?

Hi, My sprite root object rotates in  Y position when i move my character right or left? This wasn't happening, i added a new animation and now it does?

I can not figure out why!

Please help!
«1

Comments

  • The sprite cannot be on the root object of a 2D character - place it onto a child object and assign it as the "Sprite child" in your character's Inspector.  Then make sure your animation does not control the rotation of the sprite, as this will override AC.
  • Hi, i explained that wrong. Please watch video, taking not of inspector info. These only happened when i added a new animation with character holding a long object:

  • I have had this in the past :

    It may have something to do with the scaling of either the sprite or the gameobject it is attached too. i get this when one of them are not 1,1,1. 

    I can never remeber which one does it tho. sprite or parent.
  • hmmmm, bit are uniform, ie all equal, , also when i scroll through the animations i the animations panel, there is no issue...
  • see this link for animations, this only happened when i added spin and extendable

  • Oh sorry, I remember what it was for me.

    it was due to the scale of the sprite.
    But when translating from one place to another via object ->translate.
    Not using this method.


  • sorry, i don't understand. i am not using this method?
  • I was saying that when i hadf this issue, it was something else.
  • AC keeps the sprite child facing the camera by directly manipulating the "y" rotation each frame.  As you control the rotation in your animation, it's preventing this correction from occuring.  Remove the "y" rotation curve from your animation.
  • There is no y rotation curve in my anaimation? It is at 0?
  • It is working now I have removed the spin animation, but my animation will not mirror left for walking now?
  • Animation mirroring involves overriding the scale.  You will have to make sure you don't affect the x-scale in the same way.  When animating the transform of your sprites, take care to only ever animate the properties you need to.
  • Buy my x scale does not change throughout the animation of walking right?

    Please see video

  • Does it scale properly if you check Only move when sprite changes? in the Player's Inspector?
  • no that just crashes the game

    NullReferenceException: Object reference not set to an instance of an object
    AC.Char.MoveUpdate () (at Assets/AdventureCreator/Scripts/Character/Char.cs:814)
    AC.Char._LateUpdate () (at Assets/AdventureCreator/Scripts/Character/Char.cs:438)
    AC.StateHandler.LateUpdate () (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:395)

  • That error could only happen if:

    1) Your Sprite child does not have a Sprite Renderer component attached to it.
    or:
    2) Your Sprite child's Sprite Renderer has no Sprite assigned.

    Are either of these the case?
  • All Sprite childs have a sprite renderer, but not all have a sprite in that renderer as this sprite child is sometimes just a root for holding different sprites animations, pease see previous video, I leave enough time to point out the inspector window


    and this way works prefectly on other NPC's Players
  • Open up Char.cs and line 812:

    else if (antiGlideMode)

    with the following:

    else if (antiGlideMode && _spriteRenderer != null && _spriteRenderer.sprite != null)

    Then let me know if scaling works as it should if Only move when sprite changes? is checked.
  • which script am i opening?

    I willl attempt tis, although Only move when sprite changes? is not checked on my original player and that works fine?
  • It works by jove!
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.