- Home /
Weapon attach to player
Hi can anyone please tell me how i can make when player choose between weapons the weapon got attached to the hands of the player.
Do i need to make the whole character with the weapon in the modelling program or do i only need to do the arms with the weapon and then add it to the player as a child object. Or is there any way to add the weapon to the player and make the player hold the gun.
Answer by mpavlinsky · Feb 16, 2012 at 10:57 PM
You would need to model the weapon either with the point it should be attached to the player's hand at the origin or you would need to make a bone for the attachment point and position it relative to that. Then parent the gun to the player as Posly suggested, although you'll have to parent it to the specific bone transform it is intended to be attached to (right or left hand probably). In the case of two-handed weapons I would think you would need different sets of animations and to have some script assigned to each weapon that defines what type of weapon it is and what animation set it uses.
Answer by Posly · Feb 16, 2012 at 08:58 PM
You can set the guns parent as the player with "transform.parent = player.transform", just make a var with player as a transform.
But that will not change the arm animation example if i are holding a gun and it works good when i change to a ak 47 it will not be good. Because the ak is two handed weapon while the pistol is one handed.
I'd like to confirm that this works for me for holding a simple object that maintains the same orientation in relation to the player. Thanks!
Answer by kristian97 · Feb 17, 2012 at 02:22 AM
But that will not make the hand animation be good on the gun i mean if i use a gun the hand animation have to change when you change to a ak 47.
Answer by ronaldosilva · Feb 17, 2012 at 06:47 AM
Another way to solve this, more simply, is to you model the arms animation with the gun already attached. I mean, if you have 5 types of weapon, you should create 5 arms models with their respective weapons already attached. So when you choose a weapon, all you have to do is to reload the respective animated model model and trigger the "Fire" or the "Reload" animation points and thats it. Of course, tou can create bones and all kinds of complicated things.. Personaly I don´t know wich way has better performance or cost.
Answer by kristian97 · Feb 17, 2012 at 10:59 AM
I thinked like this i make a player and cut of his arms and then add to the weapon its own arms That Will be attached to the player. But the problem is That egen i Will make the pickup system how Will i make the dropped weapon without arms and when you attach it it gets arms. Also a model on the ground and another when you pick it up.
Your answer
![](https://koobas.hobune.stream/wayback/20220613064141im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Add Weapon 1 Answer
Question about network items 0 Answers
unlocking weapon (fps) 1 Answer
Detecting Input in the Start function (C#) 1 Answer
Start FPS player off with no weapon 2 Answers