fps fire unity accurate code example
Example: fps fire unity accurate
//declare a float value to control the spread factor. .02 is a good default
public var spreadFactor : float = 0.02;
var direction : Vector3 = transform.forward;
direction.x += Random.Range(-spreadFactor, spreadFactor);
direction.y += Random.Range(-spreadFactor, spreadFactor);
direction.z += Random.Range(-spreadFactor, spreadFactor);
if (Physics.Raycast (transform.position, direction, hit, distance)){