Techshop

Unity Tutorial 10 - Pushing Coins

Pushing coins

As it stands the pusher doesn't do much

Sure it stops coins on its surface, but it's not pushing anything.

The physics isn't really working well.

We need to add something and change how it interacts with the world.

First thing, we need to add a 'RigidBody' to the pusher. Also, set the "Mesh Collider" as 'convex'. However, doing that, in it's default state, it rides up. Turn off "Use Gravity".

There are a few more things we need to do.

Next we want to use to the Animation Clip to control the physics of the pusher. Instead of the Animation Clip moving the position, it will directly control the underlying physics engine. This way the inertia, motion and all the rest will pass from the animation to the object and into anything that is touching it. Before it was just moving the object directly and bypassing the physics.

To do this, under the Animator Component for "pusher" change "Update Mode" to "Animate Physics". Also under the "Rigidbody" tick the "Is Kinematic" checkbox. The first one means what we said before. The second one means that the physics will be controlled by a script, in this case the Animator script. The physics won't be calculated for the object using the engine, but the object will be used in the engine (i.e. it still counts as a physical object ).

And that's much better… (I moved the coin too)

GIT TAG 007_FixPusher

However, it's a little dull and doesn't do a lot…

Unity - A simple tutorial < Unity Tutorial 9 - Pushing things & Animation Unity Tutorial 11 - Custom Scripting >