So I’m finally getting to the point in my games where I need to animate complex objects and still have them interact with the physics system. One example is a robot arm. I want the arm to be able to move around and collide with stuff, pick things up, etc. I’m wondering what the best way to go about this is. I see 2 options.
Option 1: Create individual components of the arm and put them all together in Unity. Then animate the individual components via scripts.
or
Option 2: Model the complete arm in Cheetah and record some animations. Then in Unity use scripts to go to various points in an animation. (or maybe manipulate bones directly? don’t know if that is possible)
If I go with Option 2 how do I attach colliders to various parts of the arm and have them move appropriately with the animation?
The only way you can have real physics interactions is if you go with the physics system all the way. This probably means using hinge joints on the arm and adding forces on them with scripts.
The sane way to do it is animate it in cheetah 3d, export the animations to unity and play them with a script. Then any object that needs to be grabbed by the arm can be taken out of physics control and placed as a child of the arm’s “hand” bone. Any object that needs to collide with the arm but doesn’t need to influence the arm’s movement can use a raycast if the arm is moving and can use a rigidbody if it isn’t.
If you need the arm to be able to fully interact with things it will be very complicated and require a lot of scripting, for example a robot arm in a saw mill lifting logs and having logs fall on it that push it around and get pushed by it as well.
Jeff, you are probably best off having a single boned model for your robot arm since separate objects have more overhead. You can add colliders by putting that model into a prefab in the scene and then accessing the skeleton nodes like any other game objects to add colliders.
Each node in the skeleton has its own named transform and can be accessed and manipulated at runtime by scripts. This is the most flexible way to do it, and ensures that the robot can actually move to a particular object or put something down at a particular spot.
If you use canned animations, you can layer them to get complex movement – one animation for turning the wrist, one for bending the elbow, etc. But then you still have to do something else to determine whether the model has moved to the target position. If you can do all of that with trigger colliders to detect an object, etc., then fine, but if the robot needs to anticipate a position or something, you will still have to use math to monitor where the transform is and so forth.
The robot is going to be controlled by the user, so there is no need to anticipate positions and such, only detect contacts and have an RB attached so it can push stuff around. I’ve already figured that to pick stuff up I’d use parenting to the gripper. So it sounds like Cheetah animation is the way to go.
Thanks! Now I have to go figure out Cheetah animation…