Often there are many ways to achieve the desired result through code. The possibilities are endless and that makes programming exciting although not always as easy, a heads up; “it can get messy”.
To help us organise and plan a script we can break it down into simple parts in a language that everyone understands and is independent to any programming language, it can also help to share our idea behind our coding logic and can help to spot flaws or errors early on.
Comment out a line by adding // at the beginning of each line.
Alternatively you can comment our code blocks like so ; /*Code Block*/
Let’s say we’d like to add a Laser Mechanic to our code. We need our code to look for the Player Input and if that Input is detected, execute “Fire Laser”.
If we were to press Play in the Editor, we’ll find ourselves being able to spam the Laser Mechanic. That is because we don’t have a cool-down system for it yet. Let’s also add the logic to check if the Player is allowed to use Fire Laser, that will make it easier for us in case other features are added that don’t allow the player to use the Laser Mechanic.
We may not forget to add the actual Logic for Fire Laser, here we can specify the cool-down duration and Instantiate the GameObject. At last we add the Fire Laser Behaviour in a new script where the movement is stored and if it were to exceed a certain value, we destroy it.
Conclusion: By using pseudocode we have broken down the initial problem and worked it out further together with the errors we might encounter. We can save ourselves a lot of confusion and it helps you follow a red wire through solving complex coding problems.