Handling random numbers better

Sometimes, we need to create random behaviors that don't differ too much from a pivot point; this is the case for an aiming behavior. A normalized random behavior would shoot equally along the x and y axes, given a distance from the aiming point; however, we would like most of the bullets to aim close, because that's the expected behavior.

Most of the random functions out there return normalized values along the range given to them, and those are the expected results. Nonetheless, this is not completely useful for certain features in game development, as we just discussed. So now, we will be implementing a random function to be used in our games with normal distribution instead of a normal distribution.

Get Unity 2018 Artificial Intelligence Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.