Topic: Draw and holster a weapon

I have a character who has a gun an I want to kno how to she holster and draw her weapon

Share

Thumbs up Thumbs down

2 (edited by christougher 2016-01-14 14:08:26)

Re: Draw and holster a weapon

Will this weapon change hands when she faces different directions?

I have duplicate weapons on my characters (one in the sheath, one in each hand).  Using mecanim I modified my animations to de/activate them at the appropriate times. So the weapon in the holster is never actually moved, just for show. I use a simple playmaker FSM to change which one is active based on direction faced.   Since I switched hands I also had to modify which hit boxes switch when facing different directions. (I have UFE source).

Share

Thumbs up Thumbs down

Re: Draw and holster a weapon

Can u make a tutorial

Share

Thumbs up Thumbs down

4 (edited by christougher 2016-05-30 01:30:53)

Re: Draw and holster a weapon

Dunno about a full on tutorial, there are multiple issues here and I've been dabbling in Unity for about 10 months now myself, but how about answering some questions and I'll see if I can help out.  What do you have issues with?  I'm sure there are better ways of doing this but it works for me and gets the job done...

Do you have UFE source or Bundle? My approach required one small change HitBoxesScript.cs which allows me to swap custom hitboxes just as if they were right/left hand...  But be warned this will affect all characters custom hit boxes and (in my case) custom hitboxes 2 and 3 will work when facing right and 4 and 5 will work when facing left...  (my right handed sword has custom hitboxes 2+3 and left has 4+5).

added under     public void InvertHitBoxes

                    (hitBox.bodyPart == BodyPart.custom4 && hitBox2.bodyPart == BodyPart.custom2) ||
                    (hitBox.bodyPart == BodyPart.custom5 && hitBox2.bodyPart == BodyPart.custom3) ||

Soooo... this leads me to the next question... Will the weapons be switching hands based on which side the character is on?  I imagine so if you auto-mirroring animations in your UFE Config 'Character Rotation Options'?  This will impact how you use a melee weapon with hitboxes or where to spawn the particle effect for a gun...  Also, my characters 'magically' have the weapon switched when they turn around, There is no anim of swapping hands, it's just all of a sudden there, which works for simplicity sake, but could be nitpicked I suppose... my characters are by necessity ambidextrous.  But all in all I think that when using weapons it is probably much easier to disable auto-mirroring if it works with your game.  Much like the showcase in Horde Combat they just have their back to the camera when on the right side, but no complicated switching of weapons or hit boxes.

Any problems positioning the weapons in the different locations?  To do it like I did you'd want one parented to each hand where it looks right as well as the dummy one in the holster...

Do you have draw/holster anims?

Do you know how to edit the animations in the mecanim animation/animator to de/activate objects?  It could be done within the anim itself but I preferred to add a custom event in the animation window (a tiny pencil with a plus button) which sent a playmaker remoteFSM message to my lil Playmaker FSM.  The character prefab has the holstered weapon activated and the drawn weapons deactivated by default.  Basically for the draw weapon animation on the keyframe where the hand actually 'grasps' the weapon the animation toggles Playmaker to make the holstered weapon to inactive and both the hand weapons to active.  Then to determine which hand has an active weapon I used playmaker to check which direction the character was facing (Y rotation 0 vs 180) to toggle the wrong-handed weapon inactive. 

Hope that helped...

Chris

Share

Thumbs up +3 Thumbs down

Re: Draw and holster a weapon

I have the source bundle an I do have the animation but I'm completely lost of the other parts

Share

Thumbs up Thumbs down

Re: Draw and holster a weapon

That's a fantastic implementation!

Share

Thumbs up Thumbs down

7 (edited by christougher 2017-04-30 01:40:07)

Re: Draw and holster a weapon

Thx, I did end up making a tutorial in the character creation subforum.

http://www.ufe3d.com/forum/viewtopic.php?id=883

Share

Thumbs up Thumbs down