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.

We use OnTriggerEnter

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.

Change color to green

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! :)

Change color back to white

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.

Change the color of the cube by stepping on a trigger

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!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Janika Suhonen

Janika Suhonen

From the beautiful snowy country with a touch of "good" humor? Inspired Unity Developer to learn more.