I have an admission to make, I had already made some progress prior to creating this blog, it wasn't too substantial though and what I've done so far definitely requires some cleanup, modification, and improvements.
So what have I done?
Since I'm building my world first, I figured I would start with something that will exist in my world, animals. Since there are many types of animals that will exist, I decided that an abstract class or an interface would be needed to declare the common functionality that each animal would share, Walking, Running, Eating, etc., along with common properties, walk speed, run speed, etc. Once I did this, I made the specific animal class. In my case, I just made a cow, and inherited from the Animal class. Within the animal class, each animal will have a Wander function, which basically tells the animal to wander around the world, stop periodically for a random amount of time, then wander some more. This is a very simple function right now, but it will become much more complex later on. All it does is checks if the animal has reached a random point, sets a new random point, and then moves the animal to the new position once it's done waiting, it also rotates the animal towards the new random point to give the animal the appearance that it's turning while walking.
Impediments and Issues
- There was a very small issue I had with the cow class. Originally I had the random point set up to change within the parent Animal class, but I quickly realized that this would cause each animal to move towards the same point , then move off into random directions..
- One issue I've noticed I'm having is that occasionally, if the animal reaches the edge of the terrain, it'll 'skirt' the edge, meaning that part of it will hang off.
- On startup, the start wait time is always what I specify it to be in the editor, I need it to change to be a random value. However, When I set it to a random value in the start method, it triggers some conflicting animations and functionality when moving to the first random point.
Fixes
- I moved the random point within the individual cow class which allows the cow to set its own starting direction, rather than using a generic one.
- This issue is nothing more than correcting the bounds in which the animal can move. Changing the minimum values from 0 to 1 fixes it.
- It's likely nothing more than moving the function call to the right place in the code, or creating the random value in the wrong place. This will need to be investigated.
What's upcoming
Naturally, for functionality like allowing animals to wander around, I would give the responsibility to a manager, rather than the instance itself, so I'll be building an animal manager and attaching it to the world, to handle an animal's behavior. I'll also be adding more animals to the scene to make sure that the functionality works on each animal, rather than one, and giving them behaviors for when they run into each other. Finally, I'm going to form my terrain, which will show that the animals can move over hills, walk around trees, etc.
Wait, what's that?
If you're looking at my code for the animal class, you may notice that there's some properties and a function that are commented out and some hidden points in my scene. My reasoning behind this is, eventually, I would like to give regions to each animal type. In the real world, certain animals are native to certain areas. You're not going to see a herd of cattle wandering around the desert unless they're severely lost, they're going to be closer to vegetation and a water source. So this functionality will allow for that. What would be fun, is to eventually give the animals the ability to get lost, which would then trigger the functionality to wander the entire world.
Asset Credits
As I mentioned, I'm using models, animations, audio, etc that others have created as I have no ability in these fields.
Animal pack deluxe made by JANPEC
Zombie made by PXLTIGER
Fantasy Monster - Skeleton made by TEAMJOKER
Unity 2018.2.13f1 Personal (64bit) - SampleScene.unity - New Unity Project - PC, Mac & Linux Standalone_ _DX11_ 10_26_2018 10_34_19 AM.mp4
Aha, Yes! It's really good to see somebody else doing these kinds of things in Unity as well.
I don't know what you have planned for your terrain/level generation/loading, but I figured out a fairly simple way to get GIANT spheroid objects to work as endless terrains in Unity(30k radius, no jitters from being too large), some details over on my project blog, if you are inclined.
Either way, this is looking great so far! A far more organized and thought out approach than I took/ever take. My organization phase always comes along later after I create a righteously functional mess. On that note, if you like the whole KanBan thing, I've found https://hacknplan.com/ (kanban project management site geared for game development) to be incredibly helpful in keeping my ever growing lists of tasks in order. Their free version is more than adequate for a single person project, at least for me so far.
I also rely heavily on a mind map of the whole project for keeping the big picture clear. http://freemind.sourceforge.net/wiki/index.php/Main_Page
Anyhow, keep it up, can't way to see this progress!