2DShooterWeaponSystem  1.9.0
Bullet Class Reference

The main bullet component class for bullets used by the WeaponSystem component. More...

Inheritance diagram for Bullet:

Public Types

enum  BulletOwner { BulletOwner.Player, BulletOwner.Enemy }
 

Public Member Functions

bool GetRicochetChance ()
 Check to determine if a random roll meets the ricochet chance or not. More...
 

Static Public Member Functions

static Vector2 Reflect (Vector2 vector, Vector2 normal)
 This is a basic reflection algorithm (works the same way that Vector3.Reflect() works, but specifically for Vector2. More...
 

Public Attributes

float speed = 1f
 The speed at which the bullet will travel at More...
 
SpriteRenderer bulletSpriteRenderer
 The sprite renderer for the bullet - used to modify bullet color when bullets are instantiated if custom color is selected in Weapon Configuration. More...
 
float directionAngle
 The direction bullet is travelling in radians. More...
 
float directionDegrees
 The direction bullet is travelling in degrees. More...
 
Vector3 newDirection
 Used when calculating reflection / ricochet angles when the bullet impacts a collider. More...
 
float bulletXPosition
 Used to set bullet travel direction based on directionAngle More...
 
float bulletYPosition
 Used to set bullet travel direction based on directionAngle More...
 
float ricochetChancePercent
 The percent chance this bullet has to ricochet (set from the Weapon configuration that fired the bullet) More...
 
bool canRichochet
 Flag to enable / disable ricochet chance More...
 
bool useHitEffects
 Flag to enable / disable bullet impact effects More...
 
string bloodEffectTriggerTag
 Tag of GameObjects that should generate a 'blood impact' effect if this bullet hits them. More...
 

Properties

BulletOwner bulletOwner [get, set]
 Sample enum that allows differentiation of bullets based on whether fired from a 'player' or 'enemy'. More...
 

Detailed Description

The main bullet component class for bullets used by the WeaponSystem component.

Member Enumeration Documentation

◆ BulletOwner

enum Bullet.BulletOwner
strong
Enumerator
Player 
Enemy 

Member Function Documentation

◆ GetRicochetChance()

bool Bullet.GetRicochetChance ( )

Check to determine if a random roll meets the ricochet chance or not.

Returns

◆ Reflect()

static Vector2 Bullet.Reflect ( Vector2  vector,
Vector2  normal 
)
static

This is a basic reflection algorithm (works the same way that Vector3.Reflect() works, but specifically for Vector2.

Not currently used.

Parameters
vector
normal
Returns

Member Data Documentation

◆ bloodEffectTriggerTag

string Bullet.bloodEffectTriggerTag

Tag of GameObjects that should generate a 'blood impact' effect if this bullet hits them.

For example if you have a subject with tag 'Enemy' and this field is set to 'Enemy', when this bullet hits that subject, as the tags match, a bullet impact effect will be generated. (See demo scenes).

◆ bulletSpriteRenderer

SpriteRenderer Bullet.bulletSpriteRenderer

The sprite renderer for the bullet - used to modify bullet color when bullets are instantiated if custom color is selected in Weapon Configuration.

◆ bulletXPosition

float Bullet.bulletXPosition

Used to set bullet travel direction based on directionAngle

◆ bulletYPosition

float Bullet.bulletYPosition

Used to set bullet travel direction based on directionAngle

◆ canRichochet

bool Bullet.canRichochet

Flag to enable / disable ricochet chance

◆ directionAngle

float Bullet.directionAngle

The direction bullet is travelling in radians.

◆ directionDegrees

float Bullet.directionDegrees

The direction bullet is travelling in degrees.

◆ newDirection

Vector3 Bullet.newDirection

Used when calculating reflection / ricochet angles when the bullet impacts a collider.

◆ ricochetChancePercent

float Bullet.ricochetChancePercent

The percent chance this bullet has to ricochet (set from the Weapon configuration that fired the bullet)

◆ speed

float Bullet.speed = 1f

The speed at which the bullet will travel at

◆ useHitEffects

bool Bullet.useHitEffects

Flag to enable / disable bullet impact effects

Property Documentation

◆ bulletOwner

BulletOwner Bullet.bulletOwner
getset

Sample enum that allows differentiation of bullets based on whether fired from a 'player' or 'enemy'.


The documentation for this class was generated from the following file: