Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Best approach for animation of a 2d Charcter

Discussion in '2D' started by SgtRomeo9, Apr 13, 2015.

  1. SgtRomeo9

    SgtRomeo9

    Joined:
    Nov 3, 2014
    Posts:
    1
    Hi All

    This is my first post but I'm sure it won't be my last.

    I'm busy working on a 2d side scroller and am making use of sprite sheets for my animations, I have run into a foreseeable problem where my character will be fighting with multiple weapons and redoing each movement sprite sheet with each weapon drawn could work out to be quite a lengthy process.

    So I was wondering is it possible to simply add the different weapons to the characters hand and have just the weapon change every time. So all the animations are created without weapons even the weapon specific animations and just have the different weapons scripted to be in his hand and have there own separate animations.

    I've tried to look for tutorials pertaining to this but can't find any. Is this even possible or should I just create each sprite sheet with each weapon?

    Thank you for your help
     
  2. hasen

    hasen

    Joined:
    Apr 1, 2015
    Posts:
    29
    I've also been wondering about this. Also wondering with other animation programs like Spine, Spriter or unity assets like puppet2D work with issues like this too.
     
  3. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    Just add a child weapon GameObject to the player GameObject. The player GO does the attack animation (the animation frames you have already drawn) and the weapon GO does the weapon animation. You can swap out axe, sword etc. Of course any 2-handed weapon would require specialized 2-handed attack animations on the player GO as well. I am not sure how well they'd sync with the Animator but probably can tweak it to work. Maybe make transparent frames for barehanded and have the animator animate both the player and weapon GameObjects at same time for all attacks if possible.
     
  4. Fenrisul

    Fenrisul

    Joined:
    Jan 2, 2010
    Posts:
    617
  5. rakkarage

    rakkarage

    Joined:
    Feb 3, 2014
    Posts:
    683


    child sprites gameObjects in same animation?
     
    Last edited: Apr 29, 2016
  6. pseudokris

    pseudokris

    Joined:
    Apr 30, 2018
    Posts:
    1
    This looks like it could work for me. Could you change any of the child sprites in script? If so, how? I've been searching for a solution similar to this for a while now.
     
  7. rakkarage

    rakkarage

    Joined:
    Feb 3, 2014
    Posts:
    683