8
$\begingroup$

I'd like to make an animation of a vending machine. I'm looking for some pointers on how to make the coil turn and drop a snack.

I've made the coil from this link. The coil is on a hard surface and there are two walls on either side of the coil. I don't know how to approach the problem of getting the coil to turn and getting a box to move forward and then fall. Any tips would be appreciated.

$\endgroup$
  • $\begingroup$ Have you enabled rigid body physics for the coil(s) and boxes? And are you using Cycles, Blender Internal or the game engine? $\endgroup$ – user7952 Jan 4 '15 at 6:12
8
$\begingroup$

There are two ways you could do this:

Manually animate the coil:

  1. Make your coil a passive rigid body and set the collision shape to Mesh. This will allow the concave coil to collide correctly with the object being pushed, however you may need to increase the number of Steps in Properties > Scene > Rigid body world to avoid glitches. I used a value of 120.

    enter image description here

  2. Animate the rotation of the coil. To do this, insert a rotation keyframe (I), then on a later frame, rotate the object and insert another keyframe:

    enter image description here

    You'll notice that as I have the coil tipped 2° downwards, I'll want to rotate on the local Z axis. A quick way to rotate around a local axis is by using a rotation order with the axis in question first. So in this case, either ZXY or ZYX. See Why are keyframes in global coords, instead of local coords? (Blender 2.70a)

  3. Make your package object a rigid body. I used pretty much default settings.

Result:

Use a motor constraint:

By using this method the coil will react to the resistance of the package dragging against the tray, etc.

Also see my related answer here.

  1. Set up the coil as in step 1 of the animated method.

  2. Add a cube to act as the "motor" and mount point. I've rotated both the cube and the coil 92° so that they tilt downwards slightly:

    enter image description here

  3. Select the coil and then the cube (so that the cube is active) and press Connect in 3D view > Tool Shelf (T) > Physics > Rigid Body Tools > Constraints, then set the constraint type to Hinge:

    enter image description here

  4. Rotate the empty created by the Connect operator so that it's local Z axis is aligned with the axis around which you want the coil to rotate. In my case I've rotated it 92°:

    enter image description here

    The hinge constraint will act as a mount, holding the coil in place but allowing it to rotate around a single axis (defined by the local Z of the empty).

  5. Again select the coil and the cube (with the cube active), and press connect. This time set the constraint type to motor to add a Motor constraint:

    enter image description here

  6. Select the new empty created by the connect operator and enable Angular Motor in Properties > Constraints:

    enter image description here

    Adjust the Target velocity to control the speed of the coil rotation.

    Also note that I've rotated the motor empty 2° so that it's local X is aligned with the same axis as the hinge's local Z (for some reason the motor constraint rotates around the empties local X, while the hinge uses the local Z)

  7. Optionally hide the cube.

Result:

|improve this answer|||||
$\endgroup$
14
$\begingroup$

Once you have the coil, you need to set it in motion by adding keyframes. Go to the first frame press I and select rotation. Move to a different frame, rotate the coil and set a new keyframe by pressing I again.

enter image description here

Now set the coil to a passive rigid body.

enter image description here

Add the object on the vending machine and the rest of the collision objects. Set all of them, except for the box to be dispensed, as Passive rigid bodies.

enter image description here

Then set your dispensed object as a Rigid body but make it active. The big problem, as you'll soon see, is that the coil does not work correctly as as rigid body to interact with the dispensed box. The box goes out flying out at at the beginning of the animation.

enter image description here

The issue is that the physics for collision objects and rigid bodies is far from perfect and does not follow the real geometry of the object, but creates like a bounding box: The Coil becomes almost like a big solid object with no gaps in between.

The solution is then to turn the dispensed object into a rigid animated object for part of the interaction to force it to follow the turns of the coil, thus simulating the real motion of a vending machine.

Animate the object so it follows the movement of the coil.

enter image description here

Now all that's left is to animate the animate button. To do that go to a frame where the dispensed object has reached the edge of the dispenser. Hover with the mouse over the animate box and press I to set a key frame, Then move one frame in the time line, uncheck the animate button and press I again to add another keyframe. What you are doing is deactivating the animation settings for the rigid body and letting it act just with the physics engine. Press AltA to cache the physics and watch a preview of the object falling over the edge of the dispenser.

enter image description here

enter image description here

Here's the .blend file


|improve this answer|||||
$\endgroup$
  • $\begingroup$ Wow!! This is incredible. Thank you so much for this. I appreciate you showing also what did and didn't work. That was helpful. The "animate the animate button" part now is brilliant. Thank you again. $\endgroup$ – Alexis Jan 4 '15 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.