I have been playing around with creating first person hands by downloading some free models. What I want to achieve (or rather understand) is attaching a gun to the hands so that it they become together. I have searched all the discussions in this forum and watched some unity guides and managed to get it working but I am still getting problems with the rotation of the gun not being done properly.
I am doing something wrong but I can’t figure out what.
There seems to be a issue that the rotation of the gun is never the same in the world. For example I rotate gun in editor but the rotation is completely different in the actual scene on launch. The gun is connected but the rotation is keep on changing.
Do you mean by attaching the gun to hand manually in a model editor then creating multiple hands for multiple guns and enabling/disabling them for whichever one is selected?
When rotating it manually in the editor I could never get it to the correct position, was very weird but 1 line of code fixed it.
Just 2 noob questions I have @Albertos when I put models inside the editor sometimes they come out too big or too small. Is it possible to control how they auto-size when you drag them into the scene? or do you just need to adjust scale manually via editor/code to your liking?
and also from what I understand the best way to achieve fps hands would be to have some hand animations like 1 for assault rifles, 1 for pistols, 1 for knife etc and then attach weapons to them accordingly?
Was happening because I was attaching the weapon to the ik_hand_l and ik_hand_r nodes, the rotation is very bugged when attached directly to one hand. When I attached it to the parent ik_hand_gun it worked.
So it works with 1 model I have perfectly, I tested another model but then the same rotation issue happened again.
I think the problem is because the model that works is like this
The model that doesn’t work looks like this
As you can see on the AK the weapon is way off from the original source there is a big gap. When I do the same thing with this model the gap is visible even though the position is correct. Is this a problem with the model itself then? Or is there a way to fix this? I have the same problem with the scope that I want to attach to the first model, but theres a gap like this.
That’s a nice trick I didn’t even know this. Thanks!
I managed to get it to work, playing around with it’s position and rotation for some time.
The unfortunate thing is now the other model is rotated completely wrong, so does this mean I have to make different rotations for all different weapons then? so that all are aligned correctly with the hands?
Also with this model the hand clips through the magazine. So is the best way to overcome this to either position/size it as best I can or to just find another arm, animation or gun to achieve the best possible look?
The model is positioned based on its mesh origin. That gap you see is caused by the fact, that the mesh origin was offset from the model, when it was exported from 3D modelling application (Blender?). What you can do is to open Blender and shift the origin of the model to the location, where the gun is supposed to be attached to the bone. This way, when you add the model to the arm bone, it will correctly position itself, and you don’t need to do parent/child adjustments. Same thing for the scope and other attachements.