• Register

Scraps is a vehicle combat game where you build your vehicle from parts, and where success lies just as much in designing a well-crafted vehicle as in your combat skills. It’s about competitive creativity, and having fun while making horrible design decisions.

Scraps lets you create a vehicle that’s great or a vehicle that sucks. Maybe your vehicle falls over when it corners or doesn’t have enough power to fire its weapons – that’s okay. You decide what you drive. When you take out other players, you can scavenge from the wreckage too, and use it to repair or upgrade your own vehicle.

Currently in development for PC, Mac and Linux. Check out www.scrapsgame.com.

Twitter: Twitter.com
Facebook: Facebook.com

Image RSS Feed Latest Screens
Scraps Scraps Scraps media December 2013
Blog RSS Feed Report abuse Latest News: Scraps AI Player Navigation and Unity NavMeshes

2 comments by Nition on Mar 1st, 2015

AI Players in Scraps currently use a navmesh to work out a path from where they are to where they want to go. Unity comes with a built-in NavMesh system which is really nice and easy to use, until you want to do anything fancy. I've been trying to wrangle some better meshes out of it.

It feels like the NavMesh support is one of those Unity features that had enough work done on it to look awesome, but not quite enough to be great to use. You can set some parameters:

params

And then tell it to auto-generate a mesh based on all your static (non-moving) geometry. Here's an example on my SandyBridge map:

original

Using that generated mesh (the blue area), you can then simply ask it to calculate a path from one point to another, and it'll efficiently calculate the route. Now your vehicle (or other entity) can avoid hills etc and get anywhere effectively.

Except not really.

Entities can path anywhere within the mesh, and since they're always finding the shortest path, they'll often hug the edges. That path behaviour is unchangeable. You can't say "try to go down the middle." So the above mesh is actually too generous with its available area. A vehicle pathing on the bridge often falls off the side, while a vehicle pathing near the edge wall or an obstacle can get stuck on it. It doesn't help that scraps vehicles can be all different sizes, but the mesh must be baked to one specific size.

I can increase the Radius setting to bring the navmesh in, but that introduces another problem: The navmesh won't return a path - not even a partial one - to a target that isn't somwhere in the mesh area. Interestingly there is a path status called "partial", but it never seems to happen. Maybe it only happens when you use Unity's built in nav agents thing (which I don't use)? You might say well, maybe there's something to at least get a point on the mesh closest to a given point, like they have with ClosestPointOnBounds for bounding boxes? Then at least you could path to there instead, then go straight to the target from there? Nope.

So say you're on the mesh and the AI is on the mesh and they're chasing you, right? And they have a nice multi-point path to you that goes around a hill. But then you drive off the area covered by the mesh. Now the AI recalculates - suddenly there's no path! So it has to just drive straight at you, right over the hill.

The navmesh pathing is awesome when it works. You can even link different parts of the mesh and weight them to balance when they're chosen, like here where I told the AI it could do this sweet jump on the DustBowl map but only if it was a major shortcut:

ai_jump

You can also have different layers, with different weights and exclusions, so I can say "vehicles can drive on the hill layer if they have x or more engine power" or "only use the hills if it's this much faster than going around."

So I figure the best thing to make this work is to make sure the whole map is covered with navmesh, but there's a normal section, a hilly section, and a usually-out-of-bounds section just for chasing targets in crazy places. Then AI will be able to path anyway, but usually will only go in good places.

But the terrain can't be split up into layers. And you can export a generated navmesh to a 3D model and cut it up there (I wrote a script for it), but you can't import it back in - only generate another mesh from the first mesh, which is like photocopying a photocopy.

Using two separate NavMeshes and some 3D model hacking in Blender I added a hills layer:

hills_added

But there's still lots of empty space, and I need to fill the rest with like an "out-of-bounds" NavMesh so that things can get a path.

Can I just put a big flat plane underneath and generate a mesh off of that to fill the gaps automatically? No! The mesh has to line up nicely with the other mesh layers or it won't join up. You can use "off-mesh links" - if you want to manually place a million of them. Trying to get different layer meshes to join up is an art in itself.

Oh yeah, and if your modified mesh doesn't line up well with the actual terrain, pathing won't work either. Objects have to been within a few metres of the mesh vertically, and that parameter can't be tweaked. I understand you have to allow for stuff like the over-and-under the bridge above, but I'd love an "automatically path using the closest mesh" option. Maybe I could use SamplePosition to get the y position of the mesh instead of where the vehicle is an get a path based on that...

Anyway, I managed to hack together a system for filling the gaps in my mesh with another mesh that could be the out-of-bounds mesh. But it's a terrible process that could replace the preliminary Mensa test in terms of mental leaps required. The process sucks, and it still gets weird gaps and things in it anyway.

That isn't even everything but this post is too long already. Right now I'm working on a script that will export my terrain already cut up into separate meshes based on slope; Then I can generate the different layers I want based on that. But I'm sure that's also going to have issues when I try to generate a navmesh from it. One day I'll probably have to throw out Unity's built-in solution and use another one - preferably one where I can edit the source!

Thanks for for following Scraps' tortuous development. :)

Media RSS Feed Latest Video
Post comment Comments  (0 - 10 of 27)
Regen2100
Regen2100 Jan 4 2015, 3:54am says:

It looks really good!

+1 vote     reply to comment
PYROxSYCO
PYROxSYCO Dec 5 2014, 6:23pm says:

Fun fun fun, what is the name of the song by the way??

+1 vote     reply to comment
Nition Creator
Nition Dec 9 2014, 3:01am replied:

When I Rule The World: Billborman.bandcamp.com

+1 vote   reply to comment
PYROxSYCO
PYROxSYCO Dec 12 2014, 7:17pm replied:

Thank you! :D

+1 vote     reply to comment
swyrazik
swyrazik Apr 21 2014, 12:31pm says:

An idea similar to this came to my mind today and I'm glad that someone already started developing such a game. Keep up the great job!

+1 vote     reply to comment
cool-meatball
cool-meatball Mar 12 2014, 12:24pm says:

made a bots if already have i will be happy to download

+1 vote     reply to comment
DesuraDesuraTroll
DesuraDesuraTroll Mar 8 2014, 9:34pm says:

How fo I download?????

+1 vote     reply to comment
Sheyki
Sheyki Mar 9 2014, 3:04pm replied:

I hope you found it already, but if you didn't: Scrapsgame.com

+1 vote     reply to comment
fascka
fascka Dec 9 2013, 10:54pm says:

This is awesome, also I like the graphics

+1 vote     reply to comment
Kyou.
Kyou. Nov 25 2013, 9:24am says:

Already picturing my vehicle loadout. Hope the funding goes well.

+1 vote     reply to comment
Guest
Guest Dec 20 2013, 2:37am replied:

This comment is currently awaiting admin approval, join now to view.

Guest
Guest Dec 20 2013, 2:37am replied:

This comment is currently awaiting admin approval, join now to view.

Post a Comment
click to sign in

You are not logged in, your comment will be anonymous unless you join the community today (totally free - or sign in with your social account on the right) which we encourage all contributors to do.

2000 characters limit; HTML formatting and smileys are not supported - text only

Icon
Scraps
Platforms
Windows, Mac, Linux
Developer
Moment Studio
Engine
Unity
Contact
Send Message
Official Page
Scrapsgame.com
Release Date
TBD
Game Watch
Track this game
Share
Style
Genre
Car Combat
Theme
Fighter
Players
Multiplayer
Project
Indie
Twitter

Latest tweets from @nition

@RoyalJohnLove Personally I'm going to stay on 4.6 for a bit longer. Let other people work out some of the insanity first. :)

20hours 28mins ago

@RoyalJohnLove Cool. Yeah, wheel colliders are extra broken.

20hours 36mins ago

@RoyalJohnLove Have you managed to tame the Unity 5 wheel colliders (if you use them)? I'm getting some crazy jitter in my ported project.

Mar 4 2015, 6:04pm

@daveleaver @joshuasmyth You're thinking of PHP.

Mar 3 2015, 8:00pm

@joshuasmyth Today I finally created a nice NavMesh. Finally! Now Unity crashes whenever I use it. T.co

Mar 2 2015, 9:23pm

@tingham It would be rad to the max, if it didn't crash all the time. Argh!

Mar 2 2015, 9:22pm

I finally managed to create a nice terrain navmesh, but now @unity3d crashes when I use it :( T.co T.co

Mar 2 2015, 9:13pm

@joshuasmyth I guess I'm glad that at least I'm not making an RTS.

Mar 1 2015, 10:16pm

Talking (complaining) about AI Player Navigation and Unity NavMeshes this week. T.co #gamedev #unity3d #scrapsgame

Mar 1 2015, 8:59pm

@joshuasmyth lol navmesh T.co

Mar 1 2015, 8:52pm

Embed Buttons

Promote Scraps on your homepage or blog by selecting a button and using the embed code provided (more).

Scraps
Scraps
Statistics
Rank
993 of 24,718
Last Update
4 days ago
Watchers
229 members
News
36