Blog

Movement Scripts

I finally got to start on the Furry Kingdom game! First I decided to work on the movement script for the player, so I can have something moveing around to try out future aspects of the game. I first tried out transform movement, but I knew that wasn't really what I wanted to begin with. Then I make a script to move the player on a navmesh with the mouse. The only problem with that is that there's only one mouse and I want to have multiple players :P. So I made a script that will move the player with a rigidbody by adding forces to it. This will also make it simpler to add in a pushing attack for players to attack each other with, since I don't want the players to be able to kil each other. I also created an input asset and got the player moving around with a few keyboard keys.





Animal State Machine

Now that we have the players, I've added two animals and created a state machine for them. It took a while to set up, and it still has a few bugs, but it works great so far! There are predators that chase the player when they get close. And prey that run away from the player. They will run around on a navmesh so that I can easily have them get random places on the map to move to. They run around alright, but I can't find a good way to get them to jump up onto different parts of the navmesh even using navmesh links...





Terrains

I didn't manage to get the animals to jump up to other navmeshes so I just have them find places to move to on whatever height of navmesh they are presently on. That works. The state machines for the animals is working perfectly now. So I have moved onto creating some terrain prefabs that I can use to make the levels. The levels would get boring if they were the same design each time, and I don't want to make many different levels by hand, so I'm looking into procedural generation to make them automatically. It seems kind of advanced for me to make my own, so I'm hoping to find a tutorial on making something similar to what I need.





Procedural Level Generation

Wow! I did it! I couldn't find a tutorial for what I needed. And the ones that I did find were using Perlin noise, which I got working without trouble, but didn't look right to me. I wanted more randomness in the height of each terrain cube, but they should all either be .3 units higher or lower than an adjacent tile so that every player can reach every tile on the map. I had such a terrible time trying to make a procedral level generator of my own, but I got it now! And it works great. It even generates a navmesh for all of the animals after it is finished building the level by using "async await" and then creating the navmeshes from navmesh surface component data! Is it goofy if I feel proud? :P





4 Local Multiplayers

Well, today I finally got the basic prototype of the game done! It took some doing but I made a UI screen to let you choose 2, 3 or 4 players, the level is generated, then the players are instantiated with each one having their own input map so that they are each controlled with different keys. The main problem I was having was that they were all being controlled by the same keys.. but I finally managed to get that fixed.





Frustrum Culling

Well, now exactly. I saw that the frame rate dropped precipitously when the map is bigger. So I knew I needed to turn off their renderers. I put a trigger collider on the player along with a script to toggle colliders when they are in or our of camera view. Since there are multiple cameras I also had to keep track of how many cameras can see each tile so that they aren't turned off unless no cameras can see them. It works great and the fps is back up above 200. :)





Minimap

While testing the game I've noticed that if you aren't paying attention to which directions you've gone, you can get lost quite easily. Also, if you want to try to find the other players in the game, you're gonna have a hell of time time trying to do so. I wasn't really planning on adding another feature into this game, but it seems that a minimap is a necessity. I'm making progress on ths now, and since I already understand how it should work with a dedicated camera only rendering the terrain tiles and icons for the players and castle, it shouldn't be difficult to finish in a short time. The minimap will appear as a square in the center of the screen and can be toggled on or off by any of the lpayers with their own dedicated buttons, so they will be esy to reach.





Weather

Now that the minimap is functioning, I've really wanted to put in miniature weather systems for the various tiles ever since we began planning this game. I found a very nice set of particle weather systems on the asset store with a good discount, so I've purchase that and put the ones I like on the various tiles. They look great but they should only run while the players are near, so there won't be hundreds of particle effects constantly running. Also, I want them to turn on or off randomy, so the weather isn't always on on all of the tiles. I've created a manager script for them and they have a random chance to turn on when a player is near. They turn off when the fustrum culling oes into effect when the player is out of range.