Part 10 - 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 repository: https://bitbucket.org/hiveit/unity-tutorial-coin/src/007_FixPusher/
However, it's a little dull and doesn't do a lot…
More posts in this series.
- Part 01 - Installation
- Part 02 - Concepts
- Part 03 - Navigation
- Part 04 - Git and Unity
- Part 05 - Building a project
- Part 06 - Adding some plugins
- Part 07 - Creating some objects
- Part 08 - Physics
- Part 12 - Spawning things
- Part 13 - It is still too fast
- Part 14 - Coins are piling up
- Part 15 - Materials
- Part 16 - User control
- Part 17 - Keyboard input - Fire
- Part 18 - Keyboard input - Movement
- Part 19 - Deleting Coins
- Part 20 - Walls
- Part 21 - Adding a GUI
- Part 22 - Adding the GameController
- Part 23 - Scoring links with events
- Part 24 - Refining the Game - Part 1
- Part 25 - Refining the Game - Part 2
- Part 26 - Refining the Game - Part 3
- Part 27 - More refinements
- Part 28 - Slowing the user down
- Part 29 - Some more changes