src/entities/Player.js
/**
	* Fires a round at the player's target with the current armed weapon.
	*
	* @return {Player} A reference to this game entity.
	*/
Fires a round at the player's target with the current armed weapon.
@return {Player} A reference to this game entity.
Fires a round at the player ' s target with the current armed weapon . @return { Player } A reference to this game entity .
shoot() {
		const head = this.head;
		const world = this.world;
		const ray = projectile.ray;
		head.getWorldPosition( ray.origin );
		head.getWorldDirection( ray.direction );
		projectile.owner = this;
		const result = world.checkProjectileIntersection( projectile, intersectionPoint );
		const distance = ( result === null ) ? 1000 : ray.origin.distanceTo( intersectionPoint );
		targetPosition.copy( ray.origin ).add( ray.direction.multiplyScalar( distance ) );
		this.weaponSystem.shoot( targetPosition );
		world.uiManager.updateAmmoStatus();
		return this;
	}
shoot ( ) { const head = this . head ; const world = this . world ; const ray = projectile . ray ; head . getWorldPosition ( ray . origin ) ; head . getWorldDirection ( ray . direction ) ; projectile . owner = this ; const result = world . checkProjectileIntersection ( projectile , intersectionPoint ) ; const distance = ( result === null ) ? 1000 : ray . origin . distanceTo ( intersectionPoint ) ; targetPosition . copy ( ray . origin ) . add ( ray . direction . multiplyScalar ( distance ) ) ; this . weaponSystem . shoot ( targetPosition ) ; world . uiManager . updateAmmoStatus ( ) ; return this ; }
Fires a round at the player's target with the current armed weapon.
Fires a round at the player ' s target with the current armed weapon .
// simulate a shot in order to retrieve the closest intersection point // now calculate the distance to the closest intersection point. if no point was found, // choose a point on the ray far away from the origin // fire // update UI