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

Weapon attached to a player

Discussion in '2D' started by Deleted User, Oct 14, 2014.

  1. Deleted User

    Deleted User

    Guest

    I'm working on a 2D side scrolling game, and I could use some help with how the player holds the weapons.

    For the purpose of simplicity let's say the player holds a sword. I'd like the sword to be a separate GameObject for easy collision checking. How can I make sure the sword follows the player around (in the right place), and even rotates with the arms? So far I thought about either: Animating a bone for the sword (so the sprite can easily be changed), or animating an empty GameObject which follows the hand of the player with the pivot.

    Any ideas or general pointers? Thanks in advance!
     
  2. Deleted User

    Deleted User

    Guest

  3. DricoJD

    DricoJD

    Joined:
    Sep 3, 2012
    Posts:
    15
    I am just going to point out that separating the sword from its parent object does not make it easier for collision checking.

    use a variable for that such as:

    Code (CSharp):
    1. public Collider2D swordCollider;
    using a variable will make it easier than having it separate and this way you will not have to worry about rotation and everything like that.