Make coding simple with pseudo-code!
How can you make your code routine understandable and easy?
When I think of coding mechanics for a game I know in my mind what I need. But for making it happen in code is different.
And when I start to even think how I can make it happen I get so confused and then I get nothing done.
So I needed a simple way to code which would make my workflow much easier. And here I introduce to you our lord and savior Pseudo-code! :)
Why Pseudo-code is useful?
When coding you have to know what you need to make it work. You simplify it by writing it down line by line and start from there.
Here is an example
The player steps on a trigger and the cubes color changes to green
And a trigger object which will change our cubes color.
All we need first is a Game Object, which is our Cube.
private GameObject cube;
◼️ Make your script for the trigger and use pseudo-code to write down how the code would work.
That’s how we would write this down in Pseudo-code. It’s easier to make it happen now as we see the goal. Now we can make it happen in C#.
So we need an if statement to check if the collider is in fact our player and not something else. We do it by using Tags. We check if the Game Objects Tag is Player.
We need also need OnTriggerExit, to know when the player exits the trigger. And when this happens the color of the cube goes back to white.
You could use this for example elevate an object in a puzzle game! :)
When you have added the script in our trigger Game Object, remember to add the cube we want to change in the Game Object slot. And to change the Box collider in our Trigger to is trigger. And of course, double-check that your player has the Player tag assigned!
And now it should work! Let’s see what happens.
Awesome! We did it! So much easier with Pseudo-code. No more confusion and even people who don’t have experience in coding can understand that too! :) This helps even more in bigger mechanics but I just wanted to show you this as an example of how it is used! :)
Thank you for reading this and see you in the next one!