Join Aaron F. Ross for an in-depth discussion in this video Creating a Spring constraint, part of Creating Simulations in Maya Dynamics.
- View Offline
Our simulation is mostly set up. We just need to give it a kick to get these spheres moving on a Newton's cradle. We do that in lots of ways. I'm choosing to do that with a Spring Constraint to illustrate how that works. I'm going to select that center sphere and add a Spring Constraint. Soft/Rigid Bodies>Create Spring Constraint. Let's zoom in on that, I'll press the F key, press the 4 key and it is just a tiny little locator: that's the spring.
And you'll see that there is a line connecting the spring to the object's center of mass. I want to move that spring way out and just moving it in the X and Y axis, not in Z. I want it to maintain this symmetry here. Move that spring out there. Rewind. press the 5 key, so we can see that, and press Play and you'll see it's pulling a little bit, but it's pretty weak. We need to increase the strength of that spring. With the spring selected, I'll go to the Channel box. Scrolling down you'll see spring stiffness. Let's turn that up maybe 100 or even higher.
Rewind and play that back and you can see with the stiffness of 100, it's trying to pull those spheres towards it, but it's not oscillating and bouncing around there. What we want is we want that to just pull straight up and hold. To accomplish that, I'm going to give it a really high spring stiffness of about 500 or so. So rewind and play that back and you can see that that's really pulling them up there, but we're still getting that funky oscillation. We can tone that down by applying some Damping. So here's Damping.
And let's try value of 100 for Damping. That's a very high value, but we need a high value to match the high value of that stiffness. Rewind and play that back, and that's much better. That's about what I was trying to achieve. And now what we want to do is actually animate the Constraint. We can turn it on and off at will. I want it to be on at the beginning of the animation. So on Frame 1 the Constraint attribute is on. I want to go ahead and keyframe that. Right-click and Key Selected.
Let that play through for a couple of seconds. Now I let my Timeline go to about Frame 48 or so. I can step forward one frame at a time, if I want, or of course I can disable Solve or Evaluation. But I'm just going to choose to step forward one frame at a time until I get to Frame 48. And with my Timeline at Frame 48 I want to animate the Constraint off. I'll select the value and type in a 0, turn it off, then select a name and right-click Key Selected.
If we look at this in wireframe, it's easier to see that in fact that's got a dashed line now indicating that the Constraint value is disabled. Play that back: see what we get. We don't quite have the behavior that we want as far as the bounciness and the movement of those spheres in the Newton's cradle, but we have this structure working and we're just going to then fine-tune that and we'll do that in the next movie.
- 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