This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The [makeBullets()] function was called earlier. It calls for an amount of bullets, an amount of damage that each bullet will deal, an origin point, | |
// another point to shoot towards, a float for a range, a float for the max spread, and a float for knockback force. | |
public void makeBullets ( int Quantity , int Damage, Vector2 Origin, Vector2 Direction, float Range, float Spread = 0f, float KnockBack = 0.0f){ | |
// This entire for loop repeats for each bullet being created. | |
for( int i = Quantity ; i > 0 ; i-- ){ | |
// Gets the point where the ray will end. Uses normalized [Direction], adds a random value to it multiplied by the [Spread], | |
// which means if spread is zero, the bullets will fly perfectly straight. | |
Vector2 rayEnd = new Vector2( (Direction.normalized.x + (Random.value - 0.5f) * Spread) * (Range + rangeMod), (Direction.normalized.y + (Random.value - 0.5f) * Spread) * (Range + rangeMod)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The [makeBullets()] function was called earlier. It calls for an amount of bullets, an amount of damage that each bullet will deal, an origin point, | |
// another point to shoot towards, a float for a range, a float for the max spread, and a float for knockback force. | |
public void makeBullets ( int Quantity , int Damage, Vector2 Origin, Vector2 Direction, float Range, float Spread = 0f, float KnockBack = 0.0f){ | |
// This entire for loop repeats for each bullet being created. | |
for( int i = Quantity ; i > 0 ; i-- ){ | |
// Gets the point where the ray will end. Uses normalized [Direction], adds a random value to it multiplied by the [Spread], | |
// which means if spread is zero, the bullets will fly perfectly straight. | |
Vector2 rayEnd = new Vector2( (Direction.normalized.x + (Random.value - 0.5f) * Spread) * (Range + rangeMod), (Direction.normalized.y + (Random.value - 0.5f) * Spread) * (Range + rangeMod)); |