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