Question by
Patrick5897 · Nov 29, 2018 at 03:50 PM ·
animationweapon
How to attach weapon to player during animation?
Hello community!
I am new to Unity and I started following simple tutorials for game developing. Im already able to equip a weapon to the right hand of the player. The weapon is an axe which should be held in a natural way from the player. The thing is the player pick the weapon up from the ground an should be able to equip it during an animation. The issue is that I don't know how to set the correct position in the hand.
Wrong:
How it should be:
Code when weapon get equipped:
private void Inventory_OnItemUsed(object sender, InventoryItemEventArgs e)
{
InventoryItem item = e.item;
GameObject goItem = (item as MonoBehaviour).gameObject;
goItem.SetActive(true);
goItem.transform.parent = this.rightHand.transform;
goItem.transform.localPosition = item.pickPostion;
goItem.transform.localRotation = Quaternion.identity;
}
weapon-false.png
(151.8 kB)
weapon-correct.png
(98.6 kB)
Comment
Your answer
Follow this Question
Related Questions
How do I detect single hit on single attack? 1 Answer
Weapons holding 0 Answers
Animation keeps playing even on wrapmode once 0 Answers
How to draw weapon using the same button or key? 1 Answer
dual wielding sword Draw animation help 0 Answers