src/core/WeaponSystem.js
/**
	* Ensures the enemy does not perfectly aim at the given target position. It
	* alters the target position by a certain offset. The offset proportionally
	* increases with the distance between the owner of the weapon and its target.
	*
	* @param {Vector3} targetPosition - The target position.
	* @return {Vector3} The target position.
	*/
Ensures the enemy does not perfectly aim at the given target position. It
alters the target position by a certain offset. The offset proportionally
increases with the distance between the owner of the weapon and its target.

@param {Vector3} targetPosition - The target position.
@return {Vector3} The target position.
Ensures the enemy does not perfectly aim at the given target position . It alters the target position by a certain offset . The offset proportionally increases with the distance between the owner of the weapon and its target . @param { Vector3 } targetPosition - The target position . @return { Vector3 } The target position .
addNoiseToAim( targetPosition ) {
		const distance = this.owner.position.distanceTo( targetPosition );
		offset.x = MathUtils.randFloat( - this.aimAccuracy, this.aimAccuracy );
		offset.y = MathUtils.randFloat( - this.aimAccuracy, this.aimAccuracy );
		offset.z = MathUtils.randFloat( - this.aimAccuracy, this.aimAccuracy );
		const maxDistance = CONFIG.BOT.WEAPON.NOISE_MAX_DISTANCE; 
		const f = Math.min( distance, maxDistance ) / maxDistance;
		targetPosition.add( offset.multiplyScalar( f ) );
		return targetPosition;
	}
addNoiseToAim ( targetPosition ) { const distance = this . owner . position . distanceTo ( targetPosition ) ; offset . x = MathUtils . randFloat ( - this . aimAccuracy , this . aimAccuracy ) ; offset . y = MathUtils . randFloat ( - this . aimAccuracy , this . aimAccuracy ) ; offset . z = MathUtils . randFloat ( - this . aimAccuracy , this . aimAccuracy ) ; const maxDistance = CONFIG . BOT . WEAPON . NOISE_MAX_DISTANCE ; const f = Math . min ( distance , maxDistance ) / maxDistance ; targetPosition . add ( offset . multiplyScalar ( f ) ) ; return targetPosition ; }
Ensures the enemy does not perfectly aim at the given target position.
Ensures the enemy does not perfectly aim at the given target position .
// this distance produces the maximum amount of offset/noise