Hive Mind Roller

This unit was personalized as we did not all do the same game and i had already begun to make this game before instructed to by my facilitator. When i began with this game i had little to no clue how to begin this project. So I began with getting the basic controls down where if you click the left and right arrow keys it will rotate a platform that a ball will roll along. This is where the first issue came into play as when i coded the controls i rotated it using the transform.rotate parameter which caused the player/ball to not gain velocity when the platform is rotated causing it to drop immediately after leaving the platform. After some troubleshooting I changed the code to use rigidbody torque to rotate the platform instead which allowed the ball to interact as intended. In the beginning i began to make levels to play that you would reach the end of and go to the next level but i soon found that this would be ineffective as i would have to constantly update the game with new levels. So I decided to learn procedural generation with the platforms. I coded it so that there are two empty gameObjects that constantly compare their distance to each other and when they are a certain distance away from each other create a new platform and move one of the points to where the next platform would be created. I quickly found that i had an error as it caused the platforms to infinitely spawn in one spot and cause errors. This was because when i was trying to access the variables of the created platform i was accidentally creating a new platform which caused a feedback loop that created many platforms. I fixed this issue and then made it so that the platforms would go up or down a random distance when created unless it is close to the lava that is acting as a death barrier in which it would only be able to go up to avoid the platforms going into the lava. I coded a restart scene function that when you touch the lava the camera will stop following the ball and then after 3 seconds it will restart the level. I also created an empty gameObject that if an objects x position is less than the empty gameObject to destroy the object that passed it to avoid having hundreds of platforms at once. Next i wanted to have persistent saves that continue when you re open the project and for that I learned how to write variables to a text file upon death or quitting to the persistent data path and then load said save on the start of the level but only try to open the file if the file exists otherwise there would be an error. In this save file i began with saving the high score, the coins, and the boolean to toggle the particles. I then created a pause button that causes the time scale to go to zero simulating the game pausing and then setting it back to 1 when the button is pressed again. I then created a menu that would appear when paused that has a restart button to respawn, an options menu that at the time only has the particles toggle, and an exit button to quit the application when it is built. On the platforms i created a script that will pick a random value between 0.0 and 1.0 and if it is above a certain value to spawn a coin above it. The coin however had an issue as the animation component used world space for position and so i had to make it spawn under a parent to avoid it going to 0,0 in the world space. The platforms also had a boolean on them that upon the player touching them would disable the boolean and +1 to the score but when the boolean is disabled not to do anything.

Leave a comment

Design a site like this with WordPress.com
Get started