Posted on

Easiest Way to Toggle a Bool in C# for Unity 2020

In this lesson, I teach you the easiest way to flip or toggle a bool variable in C# for Unity. This is done by having your destination variable followed by the equals operator and the exclamation operator in front of the source variable and in this case the destination and the source should be the same variable.

Posted on

How to Use Random Range in C# for Unity

When coding for Unity in C# the Random.Range function is a very helpful function that I use all of the time. This function can be used to generate random behaviors in your game.

The most important to remember when using the Random Range function is that you must have the second parameter be plus one more than the highest number you wish to include when using ints. The reason for this is that the Random Range function normally uses float and like when you case afloat into an int, whatever decimal numbers you have will be removed never rounding up.

Posted on

Fix Script Class Cannot be Found in Unity

In this video we will be showing you how to fix the error message of scripting class cannot be found. This whole error message reads, “Can’t add script component “ScriptName” because the script class cannot be found. Make sure that there are no compile errors and that the file name and class name match.” If you are getting this error, make sure you watch this video to find the solution to this problem. By following this tutorial you will know why you are receiving this error and you know how to fix this problem. If you have any other questions about Unity, C#, or errors you are receiving make sure you tell us in the comments.