Pagina's

Monday 21 October 2019

Generating the Big Apple

So. Back in the bus again. It's been a couple of days. I made some progress in refactoring of the object generation for my terrain and I also now have a little apple model to have the characters interact with. This is important because the plan is to have default behaviour for the characters to try and satisfy their needs. Apples are here to satisfy the need for food. Can you believe it?

Before my refactoring, apples were actually functionally the same as rocks. They appeared on the terrain in a pseudo random way. This made for weird situations where there were apples around and not a single tree anywhere. To fix that, I moved an object generation method to the object script for the tree object. Trees spawn apples like they're supposed to. No trees, no apples. I don't know yet how I'm going to trigger the generation, but for now, yes get one chance top drop an apple and that's it.

I also decided not to repeat myself instantiating objects, so I moved all instatiation methods to a central script and run or with parameters. That took some debugging, but I think it works well now.


There was something off with this image, but the generation worked alright. All I had to do is make the model smaller in the prefab.  In the old system, spawning apples worked well because the scale was set from the script. Now there is not going to be much variation in apple size, so I'd better not do to much with it. So I fiddled a bit and this is the result:


Those characters better like these apples if they know how much work it was to get them there. 



No comments:

Post a Comment