Devblog
3-point turns

3-point turns

Working on the car AI has been more enjoyable than I thought. I was driving in my car today and could not stop thinking about how the car in my game needs to “think” in order to get from place to another faster.

today I completely rewrote the code for reversing the car. It actually turned out pretty good and it can easily exit even harder locations.

The pre-made car AI asset I purchased (for 12 bucks) turned out to be pretty poorly done. It was ok for making laps on a racetrack. But using it to drive a car from a parking lot to a parking lot in a realistic environment with dead ends and such just turned out to be horrible. The car sometimes eventually got to it’s destination, but it took a while and it looked like the driver had no idea what he was doing.

Eventually I figured I would add some banter for him. Him muttering aloud how he has never before driven the stick etc.. But I never had to go there as I started to understand the car AI code better and better. And today I completely rewrote the code for reversing the car. It actually turned out pretty good and it can easily exit even harder locations. The car can perform some pretty sweet Knight Rider moves and more elegant 3-point turns. It is always a bit of a surprise what it figures out to do.

A couple of minutes of my car driving itself around the Google maps data. The reversing and 3-point-turns code works better than I expected! My custom debugger is also seen here. I had to go trough a lot of hoops to get the editor and build car drive exactly the same.

The car still does not sample anything behind it when reversing, resulting in some pretty crazy situations, but I feel the I can get away without adding a code for the car to “see behind”.

Example path gameObject with some collider boxes

To help the car a little bit. I added functionality for setting the car max speed during its trip. This way I can make the car slow down before a tight turn is coming up, or speed up on long straights. It helped a lot. I also added support for per-trip group of colliders that get enabled when fast-traveling a certain route and get disabled afterwards. Just to help the car not get lost. As it is still pretty stupid! Having the car drive without fail from destination to destination is really important. As the car is driven by physics it can do some unexpected stuff. But for my use the car must be perfect and 100% reliable!

Surprisingly the most trouble I had making the pre-made assed work the same way in a game build than it does in editor. Working that out was greatly educational! As physics based code is very new to me (I have never done it before). I needed to add a lot of in-game debug text to see what the car was thinking at all times to figure out where it goes wrong.

There are still some issues where the car has nothing blocking its path, but takes forever to continue moving. This usually happens after a 3 point turn. There must be some “sweet-spot” where the Ai does not know wether to go forwards or backwards.

Also as a side-note,

using Google maps data for my prototyping allowed be to start developing the car in an actual location. Building the system in an empty environment would have just given me a car that would not have worked in the actual environment at all. Starting with a pretty good location made me face a lot of problems that I needed to solve for this to work. I feel that Google date has accelerated my project immeasurably!

New readers:

I am working on an adventure game with a pretty large, open location. I needed a fast travel solution, so I added a car that can be used to go from a point-of-interest to point-of-interest

Related posts

Car accidents (update)

Fresh screenshots of the second update to the game hero car. I also captured the car in-game and the AI crashed whthe car while filming. A lovely little thing! I added all the missing bits and bobs to the car: door handles, front bumper detail, front licence plate and fixed the overall shape of the car front to better match […]

Player Car model first pass

This week I spent a few evenings working on the car 3D model. I already knew I wanted the car to be a Chevrolet Caprice from 1987. This would be an accurate car for a detective in New York in the year 1991.

Cross-Platform & car update & UI

I spent some time refactoring the project to be cross compatible across a maximum number of devices. I had to change from High Definition Render Pipeline to Universal Render Pipeline.

3-point turns

Working on the car AI has been more enjoyable than I thought. I was driving in my car today and could not stop thinking about how the car in my game needs to “think” in order to get from place to another faster.

Fast-travel for open world point & click

An open world game will be full of vast empty areas you need to cross. I did not want to do a fade-to-black-teleport type of travel, so I figured I will give the player character a car!

Tags :

Leave a Reply

Your email address will not be published. Required fields are marked *