Week 4 - Terrain and Navigation


This week's focus was on creating a terrain and an environment for an AI to navigate. We started off by modelling an environment in Unity using the ProBuilder and Terrain Tools package that are downloadable from Unity.

I first started off by using Terrain Tools to model a partial replica of Darlington, Maria Island, as that is where the Silos (see my first devlog for context) are from. It was quite a sloppy hand job in my opinion. I couldn't quite get used to the sculpting brushes of the Terrain Tools. If I had more time to practice and experiment, I'm sure I would've been able to create a much better looking Darlington. But hey, you can at least make semblance of the beach.

Fig.1 - Darlington, Maria Island (Photo was taken by me)

Fig.2 - Terrain sculpture of Darlington

Additionally, I would've liked to know how to create a water texture, but that's out of my knowledge and I did not have the time to properly search up how to develop one. I also had a play around with the grass and tree brushes, but it caused a lot of framerate issues.

The second part, I used ProBuilder to develop a stage-like structure. I started off by modelling the jetty area in front of the silos as a base (Fig.3), before going off-script and creating whatever I wanted.

Fig.3 - ProBuilder base that is supposed to resemble the area between the silos and jetty and on Maria Island

The process of this was much easier, as I was dealing with more "blocky" designs that I find I work best with. It was quite an exciting challenge.

I placed a couple of different objects about, the weirdest one I found to be was the door (Fig.4), due to it creating a tunnel, but making the outsides transparent, which was rather annoying. I messed around with many more objects, and ended up creating an obstacle course-like stage (Fig.5).  I started off by adding blocks around the door in Fig.4 to hide the transparent outside, and then added some stairs to the roof. I added some walls and a cone object for some weird flavour. I added some pillars across the stage to make it look more busy and gave them different heights to make it seem like you could jump across them like an obstacle course. The skinny pole with the ball at the top was just me experimenting with different shapes. The two boards stretching out are supposed to represent the jetty.

Fig.4 - Door object, creating a transparent outside

Fig.5 - Full layout of the ProBuilder stage

I then downloaded the package NavMesh, which is a tool to help AI navigate their way through the stage. Fig.6 shows a blue surface covering parts of the ProBuilder stage, which is supposed to show where AI using the NavMesh can traverse. The arrows show "jumps" the AI can do. I tried to make it possible for the AI to jump to the pillars but NavMesh isn't smart enough to calculate jump distances if the two gaps are on different elevations, which is annoying.

Fig.6 - ProBuilder stage with the NavMesh surface baked on

I also added a random block that gets flung around every 5 seconds to show that when the block changes position, the NavMesh will update to account for the block's new postion (Fig.7).

Fig.7 - Flying block where the NavMesh updates according to its position

I later brought my character model from last week into the stage and used that model as a a base for me to interact with the environment. I created one for me to control and walk around, and another that was an AI (and smaller shaped) to follow the player.

I even created a script that allowed the camera to follow the player from a third person point of view with some help from antane to make the camera movement smooth and not too janky.

The hard part was dealing with AI. It wasn't a particularly hard job, but I was struggling to understand why the AI would run away from the player instead of towards them (Fig.8), to which I later realised I had some code variables the wrong way around. Fig.8 also shows the AI not animating their walk, which took a little bit of code editing to fix.

Fig.8 - AI running away from the player

Eventually, I had no further troubles and managed to also instantiate multiple AI by clicking on the screen somewhere for them to spawn (Fig.9).

Fig.9 - An AI being instantiated where the mouse is placed

I have attached my finished Unity project if anyone wishes to use, although there may be some problems as I had to delete some Terrain Tools stuff due to the zip file being extremely large.

Files

Week 4 - Terrain and Navigation - Unity.zip 2.8 MB
Mar 23, 2024

Get UTAS KIT207 Portfolio

Leave a comment

Log in with itch.io to leave a comment.