Posted on

How to Make a Random Binary Path in Unity

In this video, I show you how to create and code a random binary path which I use for our ZigZag tutorial series. A random binary path is an infinitely generating path that randomly changes directions between two directions.

In this video, I only show you how to create the initial segments of the starting platform. For this tutorial, we will talk about for loops, if statements, instantiation, and the random range function.

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

Random Range Not Working in Unity

If you are ever trying to get a random number between 0 and 1 in Unity and end up only ever getting 0 then this might be your problem and solution. One thing you might not know about Random Range function in Unity is that the second parameter needs be plus one greater than the top number you wish to have for random pick 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.