Or do, it’s your golf course!
Today’s update is a simple but functional one: We now have walls surrounding your golf course, which will let you know more clearly the limits of your course. The wall is generated automatically when the game starts, and it is updated automatically if you edit the terrain around it.
However, because the AI pathfinding is still not completely implemented, the AI will simply walk through it. Like a Boss. Golf. That will be remedied over the weekend, as I integrate a simple pathfinding system to stop the AI from trying to go to places where it shouldn’t try to go, such as the water, through a tree etc. I’ll also create the path object that you can place on the tiles to allow your AI to make smarter decisions when navigating the course.
That’s all for today, folks!
Billy Golf is now back in action! The character will now once again move to the ball, prepare himself, and take the shot. I’ve added a handful of new states to the state machine, to delegate the golf gameplay to the golfer. Now you will prepare the shot, and the little dude will move to the ball and execute it. Look at him go!
Funnily, the first couple of times he approached the ball too close, and the ball ended up colliding with himself on the way to the hole haha. But that’s been fixed. For now. Can easily be unfixed too, perhaps for some easter eggs, such as an extremely clumsy golfer.
And some of the more eagle eyed among you may have noticed a couple of other characters hanging around the golf course. I’ve added a handful of AI golfers to make things seem more lively, and will be hooking them up to the state machine this week. Hopefully this weekend I’ll get alpha 0.2 done, so that you can play the game with better golf gameplay, and see little AI people milling about your course. Hopefully also can get some walls in to separate your owned land from the rest of the land too.
Stay tuned for more and thanks for reading!
Today’s update will be a quick one, as the task is still underway.
I decided to do some test to check the performance of the current system if we use larger terrain chunks. So far, all testing had been done on a 16×16 grid, and performance was fine.
So I decided to up the ante to 32 x 32, and the performance was bad…
There was a very notable dip below 60fps, and that’s not good. Not to mention this was just a barren terrain, and that is bad. I’m sure there could be some optimization done, but it still isn’t good enough.
So I decided to redo the tile system again (third time is the charm!), this way separating the terrain into chunks of 16×16 tiles, all contained inside a single mesh. (Chunks can be made up to near 64×64, due to Unity limitations regarding vertices in a mesh). As a test, I spawned 3 chunks of 32×64, and placed it all on the scene. This is roughly 6000 tiles on display, spread across 3 large meshes.
This is the result:
As you can see, the performance stayed at 70fps range, render thread was cut by 75%, cpu remained 4ms faster, much smaller number of shadow casters, batches, and a vastly greater number of verts and tris.
So I’ll need some time to adjusting the current system to match this. The generation itself is working fine, as is the UV mapping. But I’ll need to rework the shot system since it’s all under one big mesh collider. Some things will be vastly simplified, though. And the game will run better for it!
Stay tuned for more!
Woo! Great progress this weekend.
Finished with the basic implementation of the terrain raising/lowering controllers.
You can now edit the level at the vertex and the tile level. (which raises all surrounding vertices). Simply select the desired tool (per vertex/per tile), click and drag the desired tile; up increases height, down decreases height. Simple as can be:
Though that’s less a valid course as it is a trip through hell.
Now I gotta work on the stepping levels so that the course building is less insane. Though you’ll still be able to reach insane levels if you so desire. I also want to implement a controller for edges, and one for raising up the selected tile only, similar to what you can find in the Rollercoaster Tycoon of yore.
Next perhaps a flattening tool, and even the possibility of affecting multiple vertices/tiles at once. All should be straightforward to implement with the current system. But will be in the wishlist for now.
Til next time!
Contrary to what I was speculating, the issue with the seams turned out to be simply the bleeding from the textures. It always ended up sampling at least one pixel from the adjacent texture too.
So, the fix turned out to be an easy one: rearrange the tiles inside the texture so that they are always bordered by affinity. And seams are gone!
I’ve also increased the tile size to 32×32, so I can add in more detail later if so desired. Now two things to finish off the basic implementation of the new terrain:
-Make it so the tile chooses the correct texture to display based on its neighbours
-Add controls for changing the height of the vertices
After tackling those two, I’ll need to take a new look at the shot creation system, since before it was relying on raycasts for some things still. Either change the system from raycasts to simply analyzing the grid, which could be cheaper, or turn the flat tiles into cubes so that it has a proper volume. That’s for later!
On the suggestion of a friend, I decided to take the time to experiment with procedurally generating terrain so that height can be added and give you more diversity on the golf course.
As such, I created a simple TerrainMesh class that generates a single polygon, and maps its UV coordinate according to the type of tile I want. Also implemented methods to allow me to change the Y component of the vertices, so that we can add height. So we can go from this:
Textures are now 16px*16px inside a larger 512px texture. Can easily increase the size to make it better looking if I so desire, and the system will adjust easily.
Next I’ll implement vertice control, so that the vertices can be selected and raised, and then replace the current system with this. Will also give me more control over creating other meshes to populate the tiles.
Til next time!