If you’ve ever wanted to build a game with spiders crawling on the walls, or a world where your player can walk along the ceiling, you’re in luck. In the past, it’s been a bit of a pain to get wall navigation or ceiling navigation to work in Unity. There are some asset packs out there and a couple guides on how to make it work, but now, it’s getting much easier. With the new Unity 5.6 navigation system, you can have spiders climbing your walls in just a few minutes.

Unity 5.6 Navigation System

First, it’s important to note that the navigation system updates talked about in this article are still in development and are not included in the 5.6 installer. I don’t know when they’ll be completed bundled in, but I really hope it’s with 2017.1.

Getting the Components

To download the navigation system, visit the git repo here and click Clone or Download: https://github.com/Unity-Technologies/NavMeshComponents/

The NavMeshSurface

This new script is the key to walking on walls and ceilings (or any other non-standard navigation surface).

Setting it up is quick but can be a bit confusing because options on the component change how it works pretty drastically.

Using a Single / Global NavMeshSurface

You can add a NavMeshSurface object using the GameObject->AI menu (once you’ve imported the .assetpackage).

Take a look at the Collect Objects option.

If you’re using a single NavMeshSurface on an empty gameobject, the “All” option makes sense.

What it does is bake for every object in the scene..

For wall climbing though, it doesn’t really help, because the orientation of the empty gameobject determines the orientation of the navmesh..

You could create 4 of them, rotate them in the 4 directions of the walls, and bake (and 2 more for the floor and ceiling), but I didn’t find that to be too useful personally.

Using multiple NavMeshSurfaces

Where I had more success is by adding the NavMeshSurface component to the specific parts I want the player/npc to walk on.

In this example image, I’ve created 2 cubes.

They both have a NavMeshSurface script on them with Collect Objects set to “Children”

This makes the NavMeshSurface only bake the meshes on that object and it’s own children.

To get the side wall to generate the navmesh where I wanted though, I needed to rotate the wall -90 degrees.

This is because currently the “Bake” option generates the navmesh based off the navmeshsurface’s orientation.

Linking the Navmeshes

With the current version of the system, automatic creation of links isn’t supported.

OffMeshLinks can still auto generate for the objects using the old baking system, but the new NavMeshLink used by NavMeshSurface has to be setup manually.

The documentation hints that this will be automated in the future, but for now, it’s a relatively tedious process, but it’s a tedious process that works..

To set it up, I added a NavMeshLink component to the wall.

When you add the NavMeshLink, you’ll see two little orange squares that represent the “Start Point” & “End Point” variables in the component.

If you click on them in the Scene view, you can move them around to line them up with where they should link.

Making it wide

The old offmeshlink system required you to create a bunch of links (or auto created them) so that agents could get across navmeshes at different points. Without multiple links, you’d end up with the agents walking to the center point to cross.

The new NavMeshLink component has a width variable you can adjust.

Make the link wide enough to cover the connection and the agents will walk right over to the other navmesh without going out of their way.

What’s it look like?

The end result of this simple setup is a spider that walks around on walls, jumps back and forth between the wall and floor, and pretty much ‘just works’ with minimal effort.

Of course in a full game, you’d probably want to polish up that transition, maybe with a jump or some animation and IK work, but it’s also possible that the actions so fast and your game is so active that you don’t care and can use it as is.

Making the agent walk – Testing

If you want to play with this yourself, there’s a good script in the navigation package for allowing you to click move.

For my spider I just added the “Click To Move” component. You should be able to add that to your character and see them walking on the walls or ceilings in no time.

Conclusions

While the new navigation system is awesome, it’s still under development. Some of the functionality that isn’t quite ready yet could make setting this up very time consuming. If you want to play around with wall walking, or have a small project where you can setup your navmeshes in a short amount of time, I’d say go for it. If your project is big, your navmeshes are huge, or you really can’t afford to re-work everything when stuff changes (and I’m sure stuff will change), then you may want to hold off.

Whatever you do though, it’s a ton of fun watching your characters climb walls… Now I just need to make them jump down from the wall at the player for extra fun 🙂