Unity Lab #6 Scene Navigation

In the last Unity Lab, you created a scene with a floor (a plane) and a player (a sphere nested under a cylinder), and you used a NavMesh, a NavMesh Agent, and raycasting to get your player to follow your mouse clicks around the scene.

Now we’ll pick up where the last Unity Lab left off. The goal of these labs is to get you familiar with Unity’s pathfinding and navigation system, a sophisticated AI system that lets you create characters that can find their way around the worlds you create. In this lab, you’ll use Unity’s navigation system to make your GameObjects move themselves around a scene.

Along the way you’ll learn about useful tools: you’ll create a more complex scene and bake a NavMesh that lets an agent navigate it, you’ll create static and moving obstacles, and most importantly, you’ll get more practice writing C# code.

Let’s pick up where the last Unity Lab left off

In the last Unity Lab, you created a player out of a sphere head nested under a cylinder body. Then you added a NavMesh Agent component to move the player around the scene, using raycasting to find the point on the floor that the player clicked. In this lab, you’ll pick up where the last one left off. You’ll add GameObjects to the scene, including stairs and obstacles so you can see how Unity’s navigation AI handles them. Then you’ll add a moving obstacle to really put that NavMesh Agent through its paces.

So go ahead and open the Unity project that you saved at the end of ...

Get Head First C#, 4th Edition now with O’Reilly online learning.

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