Search Unity

Need help with a sprite, Metal Slug style animation style

Discussion in '2D' started by Dr. Jade, Jul 22, 2014.

  1. Dr. Jade

    Dr. Jade

    Joined:
    Jul 22, 2014
    Posts:
    3
    Edit: Just realized I put "style" twice in the title. My bad, please ignore the first one.

    I've never been really good at explaining things, but I'll do my best.

    What I want to do is create a 2D platformer-shooter with pixel art animations, very much like the Metal Slug games. However, I'm stuck in sprite creation. Metal Slug divides a character in half so each part can play a separate animation or so. For example, while the bottom half plays a run animation, the top can play a shooting animation, or a grenade throwing animation, or a reload animation, etc. But then, if you die or interact with some object, the sprite fuses into one piece and plays one animation. How can you replicate this in Unity? Any help would be appreciated, and clarification is always available.. as I said, I'm not very good at explaining things.
     
    Last edited: Jul 22, 2014
  2. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    Well...

    As far as running a characters sprite as two (or more) separate sprites, not convenient at all. Seriously save yourself hassle and keep the characters animations all as one unless you have a darn good reason not too (which if you want to exactly emulate the style of metal slug then I guess that might be a good enough reason I am not intimately familiar with metal slug). I would stick one sprite sheet of every whole body animation set per character in, and then only use separate sprite for the weapons and stuff, nothing that is the character itself should be split up.

    Now there is one case it would make sense having everything separate sprites, which is if the bodies "ragdoll" and have to dynamically interact with collisions. This makes sense using a separate sprite not just top and bottom but every limb.

    In your case you don't need to animate firing every weapon into the anims, just make a set of anims with recoil of the hands holding a weapon, then another animated sprite for the weapon itself.

    Hope that all makes sense and maybe helps :p

    Good luck!
     
  3. Dr. Jade

    Dr. Jade

    Joined:
    Jul 22, 2014
    Posts:
    3
    Thanks for your answer,
    I'm afraid dividing the sprite is an absolute must.

    If I kept one single body frame for each animation, the movement would look... spazzy. Example: If the player was, say, running and shooting at the same time, there would be one animation for the entire body. The problem is that every time the player shoots, both the shooting animation and the movement of the player's legs would replay the first two frames or so of the animation, which would look very weird. It's possible to make the player have to stand still to shoot, but that would remove the run-and-gun element of the game.

    I'm planning on doing pixel art animation for sprites, nothing like what I think you're referring to. There won't be any ragdolling, just separate animations for the lower and upper body.

    Do you know how to replicate sprite behavior like I described in my original post? I honestly need to know how, or if Unity is even able to do it.
     
  4. Vitor_r

    Vitor_r

    Joined:
    May 23, 2013
    Posts:
    93
    I think that it's possible to do something like this in Unity.
    You will need to have 1 GameObject with 2 child Game Objects , the upper body and the lower body objects, each one of the childs will have a Sprite Renderer and an Animator, so u can control what animation will be playing on each one of them.
    You have to study more about animations in Unity, but i think that Unity can handle this fine.

    And i would accept the suggestion of MD_Reptile and make the weapon a separate Game Object too, so u can easily change their sprite without having to remake the upper body animation.

    PS: If you are planning to have a lots of players/enemies in scene with this configuration i think that so many Animators can cause some overhead.
     
  5. Dr. Jade

    Dr. Jade

    Joined:
    Jul 22, 2014
    Posts:
    3
    I already thought about doing the two child objects, but was wondering if there was any way to use just one object. Thank you both.
     
  6. Siro13

    Siro13

    Joined:
    Jun 30, 2014
    Posts:
    33
    Hi Dr.Jade,
    it's been a while,
    but I'm still interested to know if you have found a solution because I am in the same condition and I've spent a lot of days looking for a way to animate upper e lower body.
    I'd like to animate my sprite while running and attack or something else, without losing continuity.

    Regards
    Siro
     
    retroisbest likes this.
  7. sepharg

    sepharg

    Joined:
    Jul 30, 2013
    Posts:
    8
    Hi guys, it's been even a longer while, but was wondering if any of you have a good solution for this problem?
     
  8. Kaart

    Kaart

    Joined:
    Jul 31, 2017
    Posts:
    62
    The method Vitor_r suggested works fine. Create an empty GameObject and add 2 childobjects to it. One of them contains and controls the upperbody Sprite, the other the lowerbody Sprite.

    You can add all the stuff that should be shared between the lower and upperbody (colliders, scripts etc.) to the parentobject.
     
    retroisbest likes this.