Starting out: First pieces of life in the world

posted in RobbyT15
Published October 26, 2018
Advertisement

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

  1. 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..
  2. 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.
  3. 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

  1. 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.
  2. 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.
  3. 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

 

IAnimal.cs

Cow.cs

Animal.cs

Unity 2018.2.13f1 Personal (64bit) - SampleScene.unity - New Unity Project - PC, Mac & Linux Standalone_ _DX11_ 10_26_2018 10_17_09 AM.png

Unity 2018.2.13f1 Personal (64bit) - SampleScene.unity - New Unity Project - PC, Mac & Linux Standalone_ _DX11_ 10_26_2018 10_34_19 AM.mp4
Previous Entry Why I'm doing this
Next Entry Update
2 likes 0 comments

Comments

Septopus

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! :D

 

October 26, 2018 04:59 PM
RobbyT15
1 hour ago, Septopus said:

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! :D

 

I've always been pretty interested in figuring out how to get terrains to work on spheres.  It makes sense that game engines would implement that already since worlds are spherical by nature.  I'd love to take a look at your blog and learn how to do it, I've always really liked the idea because it makes creating a day and night system very easy.

My aim is to make a persistent world, like Ultima Online was, so the spherical terrain would be perfect.  I know many games don't do that anymore since it requires a constantly running environment with multiple backup environments, and it can get very expensive, but if I do end up getting to the point where I want to and can make this a viable thing, then I would worry about all that at that point.

October 26, 2018 06:47 PM
Septopus
21 minutes ago, RobbyT15 said:

I've always been pretty interested in figuring out how to get terrains to work on spheres.  It makes sense that game engines would implement that already since worlds are spherical by nature.  I'd love to take a look at your blog and learn how to do it, I've always really liked the idea because it makes creating a day and night system very easy.

Awesome, yeah, Unity doesn't do any of that by itself.  It's all my artistic trial and error that got a big ol'sphere in there without creating a complete mess.  I'm building a persistent world(universe) as well, getting the sphere working as the terrain took a bit of time for me to work out given I'm not a math guru. :D  But thankfully, it's neither super complex, nor key to the uniqueness of my game, so please take it and run. ;)  Check out my blog, hit me up if you have any questions.

 

October 26, 2018 07:20 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement