Character Joint Scripting

Not so quick question, but while I’m not yet a Unity or Javascript expert, I should ask this early on.

I plan on using Unity to set up simple scenarios that can be animated very simply by adjusting the joints of the characters in the scenario (in other words, a simple kind of game where you animate a character’s reaction to an event sort of like a puppet). I see that there are CharacterJoints that have a swingAxis, twist and swing limits. Is that where I would access the bones of a character, or is there another way to access the skeleton of a character? What I mean is, I’m not wanting to use animations at all, but I want to play around with moving the characters around like mannequins in-game. Would I instead have to make a character that is constructed of a number of meshes (discrete, jointless objects) in order to do this, or could I do this with a meshed skeleton (probably using Max, Lightwave and/or Maya)?

Thanks in advance for any response and excuse my ignorance.

Lemme see if I can help… Character joints (as well as Spring joints and Hinge joints) are pivot points for the physics engine. For a character, you would most likely use them to create a rag doll so the physics engine can take over it’s movement.

You could do this a number of ways:

Yes, this is one way, and then you could animate it either in your 3D app (as long as it supports a file format that exports animations) or do it in Unity’s animation editor (something I haven’t played with yet).

Yes, you can do this also. The bones/joints will appear as control points in your mesh when you import it into Unity. Again, as long as your app can export a file format that Unity reads that includes animations. I’m told Maya is the most seamless, but Cinema 4D also will work (through a native file reader in Unity) and Lightwave / 3DS Max will work through export to .FBX.

CharacterJoint is a physics-specific joint. It connects two physical objects. Its name comes from the fact that’s it’s primarily used in setting up joints in ragdoll rigs and such.

If you don’t want to use physics you can simply set the position/rotation of bones through normal means. Bones are just normal objects in Unity with a standard Transform component describing their location. You can move them around the mesh skin will display accordingly.

Character joints are not directly connected to bones/ skeletons. They are physics joints made for connecting ragdolls. You can attach them in any way but you will have to use the physics system. The other way to move rigged characters around is with animations. You can do a lot more than you think with the animation system. It allows for some really complex blending. Another thing you could do is just manipulate the limbs yourself with a script. in any case either separate parts like a robot or a skinned mesh will work. Even a combination of both can work.

Thanks everyone for clearing up the difference between Character Joints and the bones that exist in a mesh.

Yoggy: Are you saying I can create discrete animations for each joint, then play with the blending to get the combinations of movements to play out? I was certainly thinking of manipulating the limbs with a script once I sorted out how to control said limbs. :slight_smile:

Matthew: So if I’m certain to export the bones with the mesh I should be able to properly manipulate the joints, right? I thought this was the case, but I haven’t tested it myself.

bigkahuna: I’ll have to take a look at Unity’s Animation Editor. I knew it did blending…

Yes, you can have a separate animation for each joint. Or several separate animations for each limb. For example, in a demo I made recently I used blending to make the enemies aim their guns at you correctly no matter what the rest of their body is doing. I used the mixing transform feature to make only the head, arms and gun be affected by the aiming animations. Then I blended different directional aim states for a full 90% cone range of motion that can be easily set with a simple Vector3 direction.

Hey Yoggy was that for the Avert fate demo? Damn that looks good. Ive found that the bundled robots cant adjust their aim up and down, so if your uphill from them, they fire into the ground below…often blowing themselves up…

I did find that turning on and off a lookat script on the head of a model was a start, having him look at the camera, then switch off, then lookat again. It a long way off being usefull though.

Its times like this that I remind myself that I should stick to the art side of things, as programming just makes me feel hopeless…

ZenKen, you could definately make a bunch of animations in your art app and split them in Unity(see import settings), and call each through a different command. alternatively manipulating each joint/node via a different instruction would confuse me quickly, and may give confusing results onscreen, as one instruction may undermine another… If you do master this approach, however, it would lead to a huge plethora of possibilities that would only confuse me even more…thankfully Unity allows everyone to find their comfort zone…
AC

Yoggy: I’ll look at both aspects of procedurally manipulating joints and animation blending. Both are, I believe, scriptable. Animating may be better for smoothing/blending, but through procedurals I can play with ik algorithms. That would give me the ability to drag body parts around more like a puppet…

Targos: Yes, it would be ridiculous to imagine, but I have a specific goal in mind.

Thanks for all the input!