Breeding Animals in Unity

So I’m pretty new to both Unity and coding, but I would really like to learn. I just had knee surgery, and can’t get out of bed much, so I’d like to do something productive.

On that note, any good books or video tutorials on animal behavior, or just C# for Unity in general are welcome.

I’ve been looking around, but haven’t found much in terms of breeding animals. I’d like to eventually have a system where if any male and female is in the same area, there is a chance that they will have a baby. Following a bell curve, the baby would be 85% likely to 10% better than the parents, and then up to 40% worse and 40% better, with decreasing probabilities.

Anybody have any advice on where I can get a more in depth explanation on how to do this?

For complex problems like this the solution is to break it up into steps.

  • Identify if two animals (GameObjects) are in close proximity
  • Check a bool to determine the sex of each animal
  • Calculate a random number
  • Instantiate a new animal (GameObject and/or prefab)
  • Modify the properties of the new animal (GameObject)

That should give you enough to get some sense out of google. If it doesn’t, let us know and we will help with more concrete examples.

3 Likes