How to add LIMITLESS Variation to your Games in only ONE Line of Code! (Using Normal Distributions)

How to add LIMITLESS Variation to your Games in only ONE Line of Code! (Using Normal Distributions)

574 Lượt nghe
How to add LIMITLESS Variation to your Games in only ONE Line of Code! (Using Normal Distributions)
In many games made by beginner game developers, a lot of elements are always the exact same. To easily add more variety into our games we can harness the power of normal distributions! And the best part is we can do it in only one line of code! The magic line: private float GetRandomOverNormalDistribution(float mean, float standardDeviation) =(GREATER THAN SYMBOL) standardDeviation * -0.6266570687f * Mathf.Log((1 / Random.value) - 1) + mean; !!!IMPORTANT NOTE!!! for some whatever reason youtube does not allow the greater than symbol in its description and the magic line has a greater than symbol in it, so replace (GREATER THAN SYMBOL) with the actual symbol. Link to the full normal distribution class: https://github.com/WillHess3/Normal-Distributions/blob/main/NormalDistribution.cs This video on making Normal Distributions to help you improve your video games, is split up into 4 sections. The first section is all about how normal distributions work on a very basic level. We learn about mean and standard deviation and about the empirical rule (68-95-99.7 rule). We finally talk about how we should go about picking what value should be the mean and standard deviation. The second section is all about implementing normal distributions in our games. In this beginner's guide, I use the Unity Game Engine, but it will work similarly so long as the code is translated into the programming language your game engine uses. There are two implementations, using the single line and using the class. The single line is good if you want a quick scruffy way to add variation, and the class implementation is a little more than one line, but it's a lot cleaner. I implemented both by distributing enemy speeds over a normal distribution. The third section explains how the code works. Before I get into that I have to go in depth into other topics related to normal distributions. Like the standard normal distribution, Probability Density Functions (PDFs), Cumulative Distribution Functions (CDFs), Quantile functions / inverse CDFs, and finally z-scores. I then go through the code and show how it does what it does. The fourth section is a bonus section that goes over another way of adding infinite variation to your games, and it is probably the most important so make sure you stick around for that. Oh yeah and if you were wondering where the π comes from, this is a good video for that: https://www.youtube.com/watch?v=cy8r7WSuT1I Chapters: 0:00 - Intro 1:00 - Section 1: The Explanation 3:39 - Section 2: The Implementation 6:19 - Section 3: Context & Code 12:13 - Section 4: BONUS SECTION Subscribe: https://www.youtube.com/WillHessGameDev?sub_confirmation=1 Instagram: https://www.instagram.com/will_hess_yt Discord: Will Hess(hashtag)9883 If you have any questions DM me over Instagram or Discord