hey!
im learning unity by making a timberman game - you have a character, and a tree. The tree consist of either a left branch, a right branch or a “no branch tree piece”. The players job is to chop down the tree and dodging the branches by going to the other side of the tree (clicking the other side).
Now here’s my problem:
I want to randomly spawn tree pieces. There should be 4 pieces on the scene at all times, but only the one closes to the ground should be destroyed at each mouse click. The one above the destroyed one should move down and become the new “closes to the ground piece”, and at the same time a new piece should be spawned.
I’ve been trying to do this with prefabs but from the unity guide im not sure how to save the objects inorder to lower their y coordinates for each mouseclick etc.
TL;DR: 4 random gameObjects in scene at all times, want to lower their y coordinates for each mouseclick and destroy the furthest down object, and at the same time spawn a new random object at the top.