Forum rules - please read before posting.

Problem with flipping SUC characters with custom script

edited October 2017 in Technical Q&A
Hi

A month or so ago, @chrisicebox had created a great custom script to help me with flipping 2D characters using sprites unity complex for animation. (The script and its description can be found here)

I'd had this issue with it from the beginning, but decided to get to fixing it later. The issue is - The character doesn't flip on its center. Instead, it flips on its edge, meaning the character jumps a little distance everytime it flips. The picture attached below should make it clearer -
imageI've highlighted the axis upon which it turns in red. 

Comments

  • edited October 2017
    The character's feet and root position should be at the same place to begin with: the yellow and green circles, essentially.

    What was the link?  When flipping, does the position of either the sprite child or the root object change?
  • Sorry, think I forgot to link the script. http://adventure-creator.wikia.com/wiki/Frame-flipping_for_Sprites_Unity_Complex_characters

    I've been unable to change the position for the yellow circle, probably because it's an anima2D character (the limbs, torso and head are all imported separately, and joined together in unity. I think the yellow circle is their combined center)

    It looks like the X value of the root object changes when turning, but to a different value each turn. For example, from -15.94, to -15.97, to -15.94, back and forth with each turn. Sometimes the value shifts, to -15.95 or -15.93 and so on.
  • The position is only changing by 0.02 / 0.03 units - how large is that on your game's scale?

    The yellow circle is the centre-point of the root object, as AC places it there automatically.  The position of your Anima2D rig / spritemeshes is not fixed, but they do have to be placed correctly when first setting up the character and animations.

    It may be that you have to re-make the Anima2D rig, but I don't know what your hierarchy looks like.  You should have your Anima2D rig / SpritesMeshes parented to a shared GameObject that serves as the character's Sprite child (which should be located at 0,0,0).  It may be that adding a second child object in between allows you to reposition the whole rig/spritesmeshes without affecting the root or sprite child.
  • Alright, I'll try dissecting my character rigs again and see if I can figure out some solution. I'll let you know how it goes! 
  • @chrisicebox Fixed it! Had to realign the "bones" child object during runtime for some reason, to make sure the character flipped on the correct axis. Also checked "turn instantly when under player control" in movement settings to stop the player from revolving during the flip.
  • Strange that that should be necessary - is the sprite child correctly assigned as the immediate child object of the root?
  • @chrisicebox Yes, I'd think it's assigned correctly. The heirarchy is - 
    Player (root)
          >Player (child)
                  >Bones (child of player child)
                        >(all bones)
                        >IK

    Maybe it could've been done off runtime as well, but during runtime it changed position a bit which made it easier to predict where I should move that bones group. I'm not 100% sure of what's going on but it seems to be fixed now.
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.