Equipment Not snapping properly on pickup, need help!

Hi Unity Hivemind, Need some help trying to figure out what is going wrong in my project.

When I launch my game I can have my character start holding a sword:

GameObjectsword=Instantiate(Resources.Load(“MyPrefabs/gear/sword-simple 2”,typeof(GameObject)))asGameObject;
EquipRightHandWith(sword);

I’m trying to make it so the character can walk over the item and auto equip it so i moved that code out of void start into a new EquipTestItem void

This is the code i use to walk over the item and equip it

publicvoidEquipRightHandWith(GameObjectweapon){
weapon.transform.parent=HookRightHand.transform;
Vector3offset=weapon.GetComponent().positionOffset;
weapon.transform.localPosition=Vector3.zero+offset;

The weapon will be added, and have the right rotation but is out in front of the character. I figured it might be because it is not updated properly so I added this before the local position:

weapon.transform.position=HookRightHand.transform.position;
weapon.transform.rotation=HookRightHand.transform.rotation;

That causes the weapon to move under the hand and have the wrong rotation and position. I can disable all of this and start the character with the weapon auto equipped ensuring that the weapons offset/rotation/position are correct, but I cannot get the item to snap properly while the character is in motion.

I don’t have my code in front of me, but I do something similar in one of my projet.

Here my full procedure :

In the editor, I place my weapon in my character hand as a child. I then copy the position and rotation of the object in two public variables in the weapon script (HookScript in your case), let’s call them handlePosition and handleRotation. I then save it as a Prefab, and delete it from the scene.

And when I equip it, I call

weapon.transform.parent = HookRightHand.Transform;
weapon.transform.position = weapon.GetComponent<HookScript>().handlePosition;
//Somethng else for the rotation