As I wrote in the last post I'm going to create a Role Playing Game, so let's start with the basics of character movement.
I want to be able to move many characters using low amount of CPU cycles and still have in depth control about things like where to walk and where not (in the future a walkmap texture will be auto-generated from the level). Unfortunately the default Unity3D character controller is not very customizable in this case and so I choosed to write a custom one.
My solution is to use a simple script controlling a setup like this:
The script sense the ground height every time the FixedUpdate callback is called and adjust the Y position of the character accordingly. This way I can move freely the character being sure it's always touching the floor (for simplicity's sake all the gameplay will be 2D, completely ignoring the vertical axis).
The movement part is really simple: I'm using a 2D vector (the green line in the video) to tell the character the desired direction to go and final position is computed taking in account character specific parameters like maximum speed and acceleration.
Yes, there are still some problems when falling from an high place (see the final part of the video) and some minor ones...but it's a start :D
Even if the camera is still fixed at the moment, all the movement is relative to the camera orientation making possible to implement fixed setups like the one shown in the video (useful inside a small room) and a full-featured third person camera in a near future.
That all for now, see you next time with "my first game character" post.
Receive blog updates via email