I’m making game in which player could switch between diferent types of weapons.
But, each weapon requares its own(weapon) position, hands position and rotation angle for all of them.
The only solution I could imagine, is storing positions and rotations for all types of weapons.
Like this:
Vector3 leftHandPos_0 = new Vector3 (-0.38f, -0.72f, 2f);
Vector3 rightHandPos_0 = new Vector3 (0.29f, -0.66f, 1f);
Vector3 gunPos_0 = Vector3.zero;
Vector3 shootingPos_0 = new Vector3 (-0.02f, 0.66f, 0f);
Vector3 leftHandPos_1 = new Vector3 (-0.38f, -0.72f, 2f);
Vector3 rightHandPos_1 = new Vector3 (0.29f, -0.66f, 1f);
Vector3 gunPos_1 = Vector3.zero;
Vector3 shootingPos_1 = new Vector3 (-0.02f, 0.66f, 0f);
Cant quite get how solve this problem in more correct way.
If you’re working with models from a 3D program that you or somebody you’re working with is making (IE. not something from the asset store), a great trick is to add marker bones that signify the relative position and rotation of the weapon. Then you just set that bone as the weapon’s parent, with a local position and rotation of Vector3.zero.
Another way to solve this is to add all of the weapons to the model, and disable the renderer on the ones that are not currently equipped. That’ll allow you to position them manually.
In general, whenever you’re writing something like this:
Vector3 leftHandPos_0 = new Vector3 (-0.38f, -0.72f, 2f);
You’re probably doing something wrong. If you change the weapon model, your code wont work anymore