I’m making a weapon IK and Aim system. to make a weapon rotate around the rightsoulder depending on the direction the player was looking at, I created new gameobject “WeaponHolder”. and i maked weapons be a children of Weaponholder. but because weapons were not children of right hand, the weapons didn’t shake with the right hand while player is running. I want to make weapons move with the hands although these are not children of hands. Isn’t there any good way?
While there are good arguments for and against re-parenting such objects, the alternative to parenting is to use joints, even if that’s the fixed joint (that doesn’t move, just connects). Be warned, however, that joints are easily ‘dislodged’ by forces in counterintuitive ways. The joint design allows for ‘breakage’, which is one good reason to prefer it over parenting. A parenting relationship simply can’t be broken by forces, but joints (even fixed joints) are designed to break at certain forces (as in, the weapon can be knocked out of the player’s grasp). Unfortunately, even when set to infinity (unbreakable joint), there are still forces that can ‘dislodge’ the joint. Depending on your settings and use, you may or may not run into the problem. You can ‘monitor’ the connected object for this displacement and reset it to keep things aligned. There may be a future expansion of Unity’s exposure of the PhysX engine to include articulated joints which are better in this regard, but until then, experiment to see if this suits your application needs. It does what it does, so if you experiment and it doesn’t suit, you’ll have to consider reparenting objects. You may be able to devise strict code level control of an object, positioning the transform to subordinate to some target object, but it’s a bit tough to pull off correctly, and is merely a mimic of the parent/child object relationship performed automatically for you.