Hi everyone! I decided to draw armor and weapons for my top down 2D sprites (separate instead of pre-drawn already on the sprite). Quick question: Can I use the equipment viewer component? I tried real quick just to see. The cap I have for my player shows up, but doesn't rotate with him. Do I have to go back to switching sprites? Thanks!!
  • Im not familiar with 2D unity, but it sounds like the object (equipment viewer) isn't parented to the game object that is rotating.
    Warborn
  • The equipment viewer will simply spawn and parent the prefab of the equipped weapon/armor on the game object the component is attached to.
    I.e. whatever rotation the parent object does will also affect the viewer - so make sure it's placed under the correct parent objects to also rotate :)
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited September 19
    I tried two things. I made an empty game object called "Head," put the equipment viewer on that, no go. It just stays in the same rotation and only follows the character on top of his head. Same with just parenting it to the actual sprite. My hierarchy is only the Player with a camera child. Hmm.
    Post edited by Sierota1701 on
  • does the game object rotate or is it swapping sprites based on input?
    Warborn
  • @Wrofir Yeah, it's swapping to 2 different animations using 2 different sets of sprites. Do you think maybe using bone animation would work for the equipment viewer?
  • Yeah I think that would increase compatibility with a number of Ork elements.
    Warborn
  • edited September 20
    When you are swapping sprites, nothing really changes or gets rotated. The rotation happens inside the picture files so Engine has no way of knowing what your actual rotation is.
    Using bones could fix that, but it's not a guarantee. You kinda have to animate it the way that bone rotates like you want.

    If it's true top down game and note an Isometric or slightly tilted one, then I guess easiest method would be to actually rotate player Gameobject, if you play only Forward animations and rotate the object, then it should all work.

    P.S. if you have not already, I recommend going through Unity Tutorials first.
    https://learn.unity.com/tutorial/essential-unity-concepts#5c7f8528edbc2a002053b6c8

    They should explain how parenting, rotation etc. works.
    Post edited by hellwalker on
  • Thanks guys. I'll hit up some bone animation. I wasn't thinking ahead when I used sprite sheets, obviously. Oops :p
  • Usually having a sprite 'rotated' left or right is done by flipping the X-scale from 1 to -1 or -1 to 1. This also flips the position of the child objects (like equipment viewers), so that's probably the best option in 2D games (that don't actually rotate in 3D space).
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.