Highly Evolved Blocks
I spent some time this morning creating a couple of scripts to add some more complexity and difficulty to my levels. I’ve created a script that causes certain blocks to break when you stand on them and another which has blocks moving horizontally and vertically. This should add some flavour and spice to the mix of each level while the player is on their journey.
I added a boolean to my floating block script so that i could easily select whether i wanted the blocks moving horizontally or vertically. A boolean is a data type with only two possible values: true or false. I tell the script if the variable “horz” (short for horizontal) is true, move horizontally and if it is false, move vertically.
For the breakable block script i created a function which is called whenever the player touches the block. It moves the block left and right rapidly for a short period of time then disables the object, when the block is disabled it calls a new function which will respawn the block after another short period of time. The nice thing about these scripts is i can blend them together on the same block, so in theory i can have floating blocks that break when the player lands on them.
Here are the scripts being executed in the game engine: