Pagina's

Showing posts with label level design. Show all posts
Showing posts with label level design. Show all posts

Wednesday, 30 October 2019

A big procedural overhaul

Good morning. Let's get to it.  Yesterday, while I was working at home for my day job a mechanic showed up (it was an appointment) to change some electric stuff and that means that for a while we did not have any electricity. I decided to spend the time on thinking about Holocene. This is what I came up with:


This is what it kind of looked like before yesterday and I backed up my project because...


Well, I agree. I owe you an explanation.  Well here it is. I'll try not to make this too technical. I made some design mistakes. The most important one is that I never considered a world with any size above one Unity terrain which is about 500 meters if I'm correct. I'm sure most of you know that setting up an ancient civilisation will not work on so small an area.

What I did now is plan for a system where the world can be really big. The above image is a tile. It looks like nothing worth spending time to discuss, but it'll change. In the game, we'll have a couple of these tiles rendering while we're walking around. This fits excellently with the first person camera view, because you can only see a couple of tiles at any given time, so why render all of it?

Second thing is that with Unity's terrain system,  we'd have a landscape that does not fit well with the low poly models that I have in mind, like the mammoth. I think it'll immediately look like a weird mash up of different art styles. With this regular geometric shape landscape, I think I can prevent that and keep the artistic coherence.

Lastly, and this is tied to the big world tile thing, I need rivers and seas to have this game the way I want it to be. Water its pretty easy to implement. Just have a landscape and drop a plane with a shader on a certain height et voilĂ . Problem is that that'll make for ponds and lakes, and not for seas really.

What I plan to make is a system where some of the tiles  (don't be surprised if that's over half of them, like Earth) sea tiles. I'll probably use some smooth Perlin noise to get some magnifier for the heights on that tile. Need to find out how that'll work in practice.

Rivers will be something else. I'm not sure about that either, but in my mind, I'll have something decide a random place above some height threshold and drop a river there. That river will flow down the slopes of the landscape until it hits water. Maybe it'll have to push through when it hits a depression with hills in all sides. Maybe that'll be a little lake.

Whatever I do there, I'll have to be mindful of the time it takes to generate the terrain. It's ok to have to take 20 seconds if need be and I'm sure the generation of the world will be one of the heaviest processes I'll ever have made until now, but let's bit have it take minutes unless it's absolutely necessary and let's certainly not have it take time during runtime.

Anyway. I thought I needed this blog post to explain myself and get my thoughts to paper. When I told my wife yesterday, she was not pleased by what she saw. I'm sure she is not the only one.  Besides, the Perlin noise thing for the seas, I came up with that piece of genius during the typing of this blogpost.

Sunday, 6 October 2019

Procedurally generated frustration

Good morning everyone. I'm in the bus to work again. This weekend was pretty rich in game development. I managed to spend quite some time on the procedural terrain generation course that has had my attention for quite a while now. I learned a lot about Perlin noise and midpoint displacement algorithms and about how top make editor scripts in Unity.

Because I don't want the game to be too complex, I'm not implementing erosion for now. For that reason, I decided to just put all the scripts on my game project and get them to work before removing unneeded stuff and tinkering with the other stuff. It seems to work for a part.


This island is procedurally generated by using a midpoint displacement to generate the heights, a water plain at a certain height level and a couple of textures like grass and rock, which seem to blend too much right now. The white line is an animated shore line and the green stuff at the bottom... those are the trees.

Somehow the trees behave differently than they did in the course, so I must have done something wrong. At 11pm yesterday I decided to delete all the procedural code from my game project (only there) and start  from scratch. I am a lot more at ease with scripts with many methods than with scripts with a few large methods, so I'll have an Awake() with just about ten lines and keep it the way I like and the course teacher does not seem to.

My point is... sometimes you spend a lot of time on something without anything to show for it. Whatever I did, at least I learned from it.  I do now get that annoying feeling that I want to start working on the actual game mechanics instead of vital but secondary stuff like the terrain. I hope I'll ferry this thing working this week, because this way it does not feel like a game.

Tuesday, 24 September 2019

Mountains and valleys

So. It is taking longer for me to write new articles on this devlog. That is mainly because I am studying ways to improve on the bumpy world that I made in the previous version of Holocene. Right now, I'm working on procedural level generation again and I think it's starting to dawn on me.

In the beginning of this year, I bought a couple of Unity courses on Zenva.com to get me started on this new years resolution that I got myself into.  Now that we're 9 months along the way, I saw quite some of the hours of videos and completed some of the courses.

One of the courses is on procedural level generation.  It uses a Perlin noise to make a height map and move vertices on a grid. Then it has a heat map to make sure stuff at the equator is hotter than around the poles. That is mixed with more noise to have some randomness. Another map brings the moisture and that comes together to create biomes. All very interesting.

I am going to finish the course,  but I am not going to use it straight away,  because I want to improve it.  Firstly, water is just blue land. Making a game about guys walking around the world,  water cannot just be blue land. I know what that is about and I think I can fix that, by having the water a separate object that the navmesh can now cross. I'm not sure how to do this exactly, but I'll manage.

Second thing may be more difficult to do and less important. I don't really like the way the ground is textured, by a colour map. Some parts of the world are "boreal forest" (which is a difficult term for us Dutch right now, by the way) and that's a specific tint of green for the ground. There will be trees and plants later, but I'm not sure green floors per se will be right, and especially not the red deserts that Zenva came up with.



Next, I am not sure if the course will cover this, but I will need more  detailed stuff on the scene to interact with. That'll in itself probably be like trees which will be in the later part of the course, but I don't know yet.

Probably even more important than all the other things combined is preventing the game from taking too much resources generating the world and keeping track of it. I'm planning to have a huge world, kind of like Minecraft. Problem is that the procedural process takes quite some time on a 10 by 10 tiles grid. I know this is mainly because of building a navmesh for the tiles. That should go better later. I hope I can manage that without clogging the PC totally or else I might need to change my scope to smaller levels which would really be a shame.

Whatever will be, first I am going to finish the course and restudy the code because some of it is very poorly explained.  Then I'll tey to find the solutions.

Tuesday, 13 August 2019

Trying a different way

So the magic phrase is "procedural level generation". I opened a whole can of worms when I told myself that Holocene needed a ground that would be different from a flat plane. It got me into a whole range of tutorials for making something that looked exactly like I needed, but really wasn't.

I learned to work with Perlin noise maps  and how to use those to get a 2D configuration that looks random enough for my purpose. That's nice and it's also nice to use plane objects of home made meshes to get the level rolling,  but probably not in Holocene,  because I could not get the navmesh working. And by now you should know that this is a no-go.

The problem is that, no matter how hard I try, navmeshes end up below the surface of the level and not on top. That means that the characters would not be able to walk over the surface of the world in the way that I planned. I couldn't get it to work.

Yesterday I found another tutorial on putting what I learned to practise on an actual terrain mesh and that works if I use the special navmesh scripts that I found on the Unity github. The scripts allowed for baking the stuff at runtime which seems to work. All I need to do now is bake the mesh after generation.

I have a working navmesh now and I can now add the features to it. I am still not completely satisfied with the way the terrain looks. I think I need to tweak the noise script to allow for more flat regions, but for now it works. Next is to turn this into a game.

Sunday, 11 August 2019

Building the world

Alright, I've been quiet on the blog recently. That's because I mean to have a big change on the game. The change is about level building. Holocene is a Real Time Strategy game and those games should be replayable, but that only works is the playing field is more interesting than just a flat plane and if it's different every time you play the game.

For that reason, I studied procedural level generation for a couple of days. It works by putting a plane in the scene and having vertices inside of it go up and down according to some noise thingy that I do not yet totally understand. The idea is to get the plane to resemble a sort of low poly terrain.

Next, there'll need to be some changes in the different scripts to allow for the third dimension that we have now. In fact, Holocene may look like a 3D game already, but it's the famous thing with the ant that quantum physicists always say when they explain the multidimensional world they think of. An ant is walking on the pavement like its 2D. There is no up or down for it. Well, the objects in Holocene should turn from ant to human.

I'm starting to get the gist of the level creation and I think I might be able to use the same script with some modifications once I build a campaign mode, but right now, I am not yet satisfied with the way the terrain looks. It's too bumpy and not mountainous enough. It's too all-the-same to my taste and I'll need to change that, because we need valleys and mountains, not just one 6 meter high hill following another.

I need to get the noise changed. While there's the Perlin Noise, I need to tweak that. I need lower the frequency so that we don't get hills everywhere we could get. We're trying to run a civilisation there, right? Next, we need higher amplitudes, because we need mountains and valleys. Lastly, I need to add more noise within the noise so that it does not look the same everywhere we look. We need hilly parts, flat parts, sea and mountains. And everything in between.

Looking at the code I have now, that must be feasible.

Friday, 8 February 2019

My top-down RPG-adventure

Well, it's not going to be Skyrim yet and it does not include anything like a massive world, as far as I can foresee, but I got to building my first game yesterday evening. It's going to be a simple top-down game with my stick figure walking around.

I have my walking pixel art stick figure prancing around with a lot of #swag, according to my colleagues and this is our hero. It is he who will make his enemies tremble in fear and it is he who is going to open doors, pick up health potions and, most importantly, guide my programming advancement.

I have figured out how to make use of this animation via a style sheet and how to have him walk to a certain location, from the Unity Codemonkey tutorials. I also made a simple level building system to add wall objects from a small PNG file to the scene in Unity. I might need to tweak that a bit, but I have enough of that for the time being. 

Next will be creating the Stick Figure object and adding all its components. I'll pobably need prefabs for that (and for the walls too), so I'll have to focus my efforts to this matter, this weekend. Hopefully, there'll be a basic character system by the end of the weekend and then I can start making more of these nice animations too.