Forum rules - please read before posting.

Pivot points and different sprite sizes

When my character walks, what's going on is basically that its game object is being moved until its sprite pivot point coincides with the navigation point I made it walk to, right? Which is why we have to always place the pivot point at the bottom of the sprites.

When walking to the right or left it's easy enough, because all the sprites can have the same bottom point, and thus the spacing between the feet of the character and the pivot point of the sprite can stay the same in all frames. But when walking up or down, the bottom point of the character changes (because of the perspective on it's feet). I see that in the 2D Demo all the sprites have been made the same size simply by adding some extra transparent pixels at the top and bottom of the sprites, which allows the pivot point to stay the same in all frames.

This however seems to come at the cost, that the character will always position itself just slightly above the actual navigation point you made it walk to. In the case of the 2D Demo it's not really noticable, since the transparent gap at the bottom of the sprites is relatively small.

But what if I want to have some animations that don't allow for this fix - say, if I want the character to swing a sword in front of himself while facing down? If I place the pivot point at the bottom of the sword_D sprites, that would make those frames 'jump up' compared to the idle_D frames - and if I make all my character sprites large enough to allow for the extra sword stuff while keeping the same pivot point relative to the character's feet, that would create a rather large transparent gap between the feet of the character and the actual bottom of the sprites - which would in turn mean that the character would position itself unacceptably far above the navigation point you made it walk to.

I guess one fix could be to make the feet of the character always coincide with the middle of the sprites, set the pivot point to the middle, and then have large transparent gaps in all sprites in the directions where I want to allow for extra stuff. But I'm not sure if this will cause problems with regard to some of the other functions? And perhaps there is a much better way I haven't thought of?

Comments

  • A character's "origin" is determined by the position of their root object - the location of the sprite / pivot point only affects his appearance, since the sprite is on a child object.

    The height or relative scale of a sprite is not a factor - only the location of the sprite's pivot point.  The sprite child must have a local location of (0,0,0), i.e. at the same position as its parent.  The pivot point of the sprite affects his percieved position in the scene.

    In most cases, setting the pivot point to the very bottom is good enough and can be assigned quickly.  You can, however, be more accurate by moving the pivot point exactly between their feet (which, as you've seen with Brain2D, is actually a few pixels above the bottom).  If you want a character's sprite to go "lower" than their root object, you can just raise the pivot point for those particular frames.

    Alternatively, you could move the sprite to another child object (so that your hierarchy is effectively Root -> Sprite child -> Actual sprite), and then incorporate movement changes to the actual sprite within the animation clips themselves.  The "sprite child" must have a zero local position, but any children it has can be placed wherever you like.
  • Thank you @ChrisIceBox !

    I was thinking that navigation was based on the pivot point, but of course it makes a lot more sense with the root object position. I think I understand 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.