Dodge the Giant Spinner of Death!
Finishing off the year 2023, I decided to try something a little bit new and simple to see how far I come, I made a simple little obstacle course to see if I was missing anything that I already should have learned and improved with making mechanics before making more complex mechanics and design in games.
For the first time, I decided to simply use Cinemachine to test out the smooth virtual camera to follow the player.
The goal of this game is to reach the goal while avoiding obstacles as much as you can before time runs out. Don’t collide too many obstacles, or you lose!
I did the best I could to not overload the player with so many obstacles at a time, otherwise, it would be overwhelming and difficult for them to dodge the obstacles.
I needed to make sure the was enough room for the player to move around and dodge obstacles, especially the dropped obstacles which I intentionally put close to walls so the player can navigate around them a little easier after being dropped. The giant spinner of death I wanted to be the main threat to the player so the player is forced to keep their eyes on it at all times otherwise it will collide with the player and knock them towards another wall or obstacle.
I put a timer in the game to challenge the player to get to the end goal in time before it runs out. It would be a little too easy and not as challenging for the player if there was no timer since they could just wait a long time before all obstacles are dropped and go slow and steady around obstacles.
WHAT I IMPROVED:
Combining 2 strings and an int making into one sentence with a number countdown which is “you have” + “seconds” + “secs left”.
Got into the habit of making code much cleaner to read by separating some code into functions to avoid writing the same code again, So instead It calls certain functions at appropriate times ( e.g if the player loses by colliding too many objects or time ran out, it calls the function “displayLoseText” to display lose text.
WHAT I LEARNED:
How to set up the virtual camera from the cinemachine package.
How effective it is to make the cinemachine virtual camera smoothly follow the player.
How to turn on and off gravity on game objects by code.
It’s a good idea to start variables with lowercase letters.
Get axis movement is a method.
Delta time makes updating independent by making the time of frames consistent with the user’s computer. It uses the getaxis value multiplys by delta time movement value speed consistent with the user’s computer as it creates a single value.
The spinners that move without using delta time when timescale is 0 will still move. Possibly due to the fact it's not accessing time as it moves on its own.
Using Enumerators to drop obstacles in certain periods of seconds instead of using Time works best if the game level needs to be played again if players lose or win, otherwise the obstacles will not reset is drop counter and drop too quickly because Time has not been reset to zero when replaying the level.
Can change game objects tag names in code.
Tag is actually a property.
OnCollisionEnter is a callback.
Collision is a variable while "other" is a parameter. “other” stores information about what the gameobject might hit and what it might do with that information. I’ve known OnCollisionEnter for a while, but it's good to know more details about it.
Rotate (transform.Rotate) is a method. Methods are in capital letters.
The difference between defining and calling a method.
WHAT WENT WRONG? WHAT I COULD HAVE DONE BETTER?:
I couldn’t get the walls to always stop the player in its tracks, it is a difficult problem to solve. It could be because the player is moving so fast that it can pass through thin walls. I could have made thicker walls.
The player can also pass through walls by holding a move key as soon as the play button on the unity editor is pressed. The player can pass through corners for some reason, I tried to cover the corners as best as I could, but there was no luck succeeding. Thick walls wouldn’t be right for an obstacle course since most of the walls needed to be avoided by the player. So, the easiest solution I did was to add a timer that would pause the game and offer the player to try again if time is up.
When the player moves towards the wall, it shakes rapidly. I tried to see if I could give it a physics material to reduce the wall shaking, but for some reason, it had no effect, so sadly I had to let it go. I will need to find out more about creating physics materials to make it work as intended depending on the game mechanics and player collision.
OVERALL:
Even though I knew most of these data types beforehand, I learned some new details about them which is important for me to understand and how they work so I can work with them (or around them).
I need to get an understanding of some knowledge I may not have known 100% before (e.g. How player cube is not so bouncy on walls) and may need to research more to prevent or reduce the unwanted executions from code.
I could have tested it with a player, but I thought it wasn’t too important for now. The intention was to be more of a programming exercise to see what I know and what I don’t know, not a playable commercial game that the public can play.
Comentarios