Hi. I have a 3D humanoid character in a 3rd person view. I’ve run into a problem and I want to move the character’s hands by giving coordinates manually, either hardcoding or from a CSV file.
How can this be done?
You’ll need to describe what you’re looking for better. Better yet, post a video that shows exactly what you want, since describing things can be complex.
In general, it vaguely sounds like you want some kind of Inverse Kinematic solution to allow you to move the player’s hand bone to a given location, and have the arm (and maybe even the rest of the character) move along with it.
Yes Sir, that’s exactly what I am looking for. The rest of the character doesn’t need to move along with the hand, only the hand and the arm are to move. Can you kindly provide a piece of code or point me in the right direction so I can understand how to implement it?
You’re talking about Inverse Kinematics then, which means moving/rotating a child object (the hand) and having the system figure out how it needs to move/rotate the parent(s) of that child to get everything cleanly into a new position.
This isn’t something that Unity does automatically, as far as I’m aware, and the code to do it isn’t simple at all. It usually has lots of constraints around joint behavior, like which axis a joint can rotate on, how far it can rotate, etc. (Think about how your elbow only allows one axis of rotation, and only allows about 180 degrees of rotation before you can’t extend you arm any further.)
Anyway, this isn’t the kind of behavior you’re going to get in a “piece” of code. Either just try googling for a free solution, or try the asset store:
There are some free IK solutions, and some expensive ones. I’ve never used any of them, so I can’t recommend one over another.
Actually Unity does have a built-in IK system, but some coding will be required. There’s some example code in the manual that looks pretty close to what you’re trying to do, though.
Thanks for pointing that out. Definitely something I missed and will look into.