Join Aaron F. Ross for an in-depth discussion in this video Keying the active attribute, part of Creating Simulations in Maya Dynamics.
If you want the best of both worlds from traditional keyframing in Dynamics, you can do that in Maya simply by keying the active attribute on a Rigid Body node. We can set it up so that the object will be keyframed in the first part of an animation and then allow the Dynamics to take over. This is a really cool technique that you probably will use a lot. In this version of the scene, my ball does not have any Rigid Body nodes attached to it yet. What you usually want to do in this case is you want to create a passive rigid body to start with.
We've got it selected. In my Dynamics menu set, I'll go to Soft/Rigid Body>Create Passive. And as I mentioned before, there's only one Rigid Body node type and whether you choose Active or Passive in this menu, you'll create the same node. The difference is the state of the active attribute and if I go to the Channel box and open up that Rigid Body Shape node, scroll down near the bottom, then you'll see Active and it's currently off.
In this state now, I can create ordinary keyframes on the ball. However, I do want to verify that my Rigid Bodies Solver is globally disabled so I don't have any performance issues. I'll just verify it by going to Modify> Evaluate Nodes and we'll turn that Rigid Bodies off. I just create keyframes in the ordinary way, position keys in this case for that sphere. By the way, you'll see once again that these channels are highlighted in yellow and ordinarily that means that there's some incoming connection that's taking over your ability to keyframe.
However that's a little bit misleading. in the interface here. That yellow color does not indicate that there's some incoming connection that's preventing us from keyframing the object. It simply means that those attributes are connected to something currently and they're connected to the Rigid Body node, but the Rigid Body node active attribute is turned off. That means we can go ahead and keyframe this and not worry about any problems coming up. I do want to keyframe it just in X and Z once again and on Frame 1, I'll select X and Z and key those attributes.
I'll go to a later point in time like let's say Frame 12-- see that in the Top View-- it's a little bit clear, grab that Move tool and in half a second, how far will it have traveled? Let's say about quarter of the way down the length of the alley. And I want to key those attributes once again and rewind that, play it back and you can see, boom, the ball is moving down the alley, as we expect. Now I don't want any weird interpolation here.
I want that to just be a straight line and I want it to be a linear interpolation. With that sphere selected, once again I'll go into the Animation Editor>Graph Editor and I want to press the F key to frame those curves and select them and this time I want linear interpolation, so I'll choose Linear Tangents. Now the ball will move in a perfectly straight line. So that's the first part. Now the second part that's really fun is to enable the active attribute. I'll scroll down here and here's the active attribute.
It's currently off and on Frame 1, I want to key it off, select the name and key selected. We have animation up until Frame 12 and what we need to do is we need to reenable the attribute while the object is in motion in order for this to actually take over and inherit the vector-- in other words, for it to know what direction the object is moving and how fast. In order for that to work correctly, we can't key the attribute back on after the animation is finished, we need to go back a couple frames.
The second keyframe here was on Frame 12. I'll just go back to Frame 11 and on Frame 11, I'll key the active attribute on, typing in a 1, press Enter, select the name and then key it. By the way you will notice that you don't see the keyframes for the actual Transforms in the Timeline here. It's just a quirk of the interface. We don't see the keyframe on Frame 12 here, we only see the keyframes for the actual Rigid Body Shape node.
But if we go into the Graph Editor once again, we will see all those keys and we have got Translate X here and that's got keyframe data on it and we have got the active attribute here as well and I want to select that and press the F key and you can see that the active attribute is binary, in other words it's only on or off. There is no possibility of a transitioning with an interpolation any of these tangent types. It will always be a step tangent, because active is binary. Rewind and play that back.
Cool! So now let's try seeing what we get here. Tap the Spacebar, go back out to our four -viewport layout and then we'll go back and reenable the Solver, Modify> Evaluate Nodes>Rigid Bodies. Rewind and play that back and you can see that in fact the Dynamics have taken over. I only animated the ball from Frame 1 to 12 and then I have turned the active attribute on, on Frame 11. We don't see the ball falling to the ground, because it is not connected to gravity and that's easily fixed, select the ball, select the Gravity field, then go to Fields>Affect Selected Object(s), rewind and play it back.
It's basically doing what I want. If I wanted a more realistic result of course, I would probably want to animate the ball in Y, so it would fall instead of just flying through the air. But that is a very good illustration of how we can keyframe the active attribute to combine traditional keyframe methods with Dynamics.
- Choosing a scale convention
- Laying out the scene
- Modeling proxy objects
- Creating passive and active rigid bodies
- Imparting an initial velocity
- Improving performance
- Applying damping
- Adjusting mass
- Adding a Radial field
- Keying the Active attribute
- Baking the simulation to keyframes
- Creating Hinge and Spring constraints