### Show differencesHistory of post edits

### #ActualTom KQT

Posted 08 January 2013 - 02:21 AM

Now with accuracy:

rayOrigin will be the same.

And about rayDirection - each weapon could have its precision defined as the maximum angle the shot could go off the ideal centre (for example 5 degrees).

You would generate a random number from 0 to this maximum angle and rotate the rayDirection around the rayOrigin point by this random degree lets say to the right. So, for example, if the random number was 2.1 degrees, the shot at this stage would go exactly 2.1 degrees to the right of the ideal direction.

And as the next step, you would generate a random angle from 0 to 360 degrees (so a full "circle") and rotate this new direction vector around the ideal direction vector by this amount.

As a result, the shots can go randomly anywhere around the ideal target and only by a limited (but random) distance from the target.

### #2Tom KQT

Posted 08 January 2013 - 02:20 AM

Now with accuracy:

rayOrigin will be the same.

And about rayDirection - each weapon could have its precision defined as the maximum angle the shot could go off the ideal centre (for example 5 degrees).

You would generate a random number from 0 to this maximum angle and rotate the rayDirection around the rayOrigin point by this random degree lets say to the right. So, for example, if the random number was 2 degrees, the shot at this stage would go exactly 2 degrees to the right of the ideal direction.

And as the next step, you would generate a random angle from 0 to 360 degrees (so a full "circle") and rotate this new direction vector around the ideal direction vector by this amount.

As a result, the shots can go randomly anywhere around the ideal target and only by a limited (but random) distance from the target.

### #1Tom KQT

Posted 08 January 2013 - 02:18 AM

rayOrigin is the position of the gun (position vector) and rayDirection is the vector towards the ideal centre of the crosshair (direction vector), right?

Now with accuracy:

rayOrigin will be the same.

And about rayDirection - each weapon could have its precision defined as the maximum angle the shot could go off the ideal centre (for example 5 degrees).

You would generate a random number from 0 to this maximum angle and rotate the rayDirection around the rayOrigin point by this random degree lets say to the right. So, for example, if the random number was 2 degrees, the shot at this stage would go exaxtly 2 degrees to the right of the ideal direction.

And as the next step, you would generate a random angle from 0 to 360 degrees (so a full "circle") and rotate this new direction vector around the ideal direction vector by this amount.

As a result, the shots can go randomly anywhere around the ideal target and only by a limited (but random) distance from the target.