Search Unity

Character question

Discussion in 'Editor & General Support' started by elias723, Jul 10, 2006.

  1. elias723

    elias723

    Joined:
    Feb 10, 2006
    Posts:
    178
    Hey everyone. I a few questions about characters that hold guns. I want to do animations with both the guns and the people at the same time (ie the gun responds to the motion of the hand). I saw that the guys who made the FPS example made the robot and the gun parts of the same Maya object.

    1. What are the benefits/downsides of doing this as opposed to making them seperate objects?

    2. In this situation can I switch weapons or do I have to switch my entire model out for a new one holding the new weapon?

    3. Could I do the weapon and the person as seperate things and try to make the animations line up with each other?
     
  2. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    If you want switchable weapons the best way would probably be this.

    In your .mb file, make a transform called holder and place a gun on it. Now make sure to not animate the gun but only this holder node.

    Since you probably want to keep all your guns and all your guys in seperate files, you will want to attach the guns to the holder nodes inside of unity. You can either do this in the gui or from code using
    Code (csharp):
    1.  
    2. transform.parent = theNewParent;
    3.  
    When switching weapons you just activate / deactivate the right gun model. Similar to how we do it with the first person controller and the rocket launcher / machine gun. (See WeaponSelector.js in the fps project folder)
     
  3. elias723

    elias723

    Joined:
    Feb 10, 2006
    Posts:
    178
    I think I see what you're saying - make a spawnpoint for the gun in Unity. I can do this kind of thing with my Blender objects. Maybe I'm missing something that you're saying with the holder "node" animation, but I don't think you understand my question.

    What I mean by animations is doing something like having the hands in front of you turn the gun sideways and shove a new clip in or cock the gun etc. etc. It doesn't seem like I could do this as well as switch weapons the way you are suggesting I do it. Could you please clarify for me?
     
  4. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    The robot guy had an animation that shoots and then goes back to a normal pose. Similar to that you would add another animation that goes to a pose where you want to switch the weapons. When that animation has finnished playing you do the activate / deactivate trick and then play a move animation back into normal pose animation.
     
  5. elias723

    elias723

    Joined:
    Feb 10, 2006
    Posts:
    178
    So with that said, I would need to animate the character differently for each weapon's functions and call the animations by gun and function. I would also need to animate the guns in their own files, right? Or do the "nodes" (I still don't understand this term) in the player file act to animate the gun?
    Thanks again for the help.