Wednesday, 6 April 2011

Unity Tools - Movement

Starting in Unity my first job was to just basically get an object running left and right on a flat surface. Using a very basic blocky placeholder of a chameleon, I imported it into unity and tried to find a script that would allow it to move left and right on the X and Y axis.  As Ecotone is a 2D platformer/puzzle all movement/values in the Z axis will have to restricted and set at 0.

Using the ‘Platformer Controller Script’ I used in the ‘Unity 2D Gameplay Tutorial’ some time ago, I imported the script into my project to use in my prototype. The Platformer Controller Script allows an object to respond to keyboard input, including moving left and right with arrow keys, jumping with space bar and running by holding the alt key whilst moving. The variables speed, gravity etc can be adjusted in the script settings.


The first obstacle I encountered was for some reason the character wasn’t sitting on the plane. It would hover slightly above the ground and run left and right in mid-air. At first I thought it might be something up with the model but then I remembered in the tutorials that the character controller works with a Capsule Collider which is a capsule around the object which determines how it interacts with the rest of the world. The Capsule Collider my object went way below the actual model (See image above) so all I had to do with scale the Collider to fit inside the model correctly.

No comments:

Post a Comment