There's more...

Our character is not very smart-it can collide with objects, but it cannot do any path finding. You can implement a 3D path finding solution (based on a graph of points in space, for instance) or use one from the Asset Store. You can also use Unity's standard built-in NavMesh Agent to find the path on the terrain and only control the height of the character.

You can also switch between flying and walking modes by setting a target point on the ground for the character to land, checking the ground with a Physics.Raycast() method, and turning the gravity back on and implementing the Using root motion to steer a character recipe to move the character when grounded.

Get Unity 5.x Animation Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.