Energy Based Objects  2.01
Public Member Functions | Public Attributes | Properties | Events
Bullet Class Reference

Super simple bullet physics. More...

List of all members.

Public Member Functions

void AddForce (Vector3 force, ForceMode forceMode)
 Add a force to move this Bullet
void WakeUp ()
 Stop sleeping.

Public Attributes

Vector3 velocity
 Current movement velocity.
Vector3 gravity = Physics.gravity
 A mysterious force.
float mass = 1
 Weight.
float drag
 Slow-down amount.
float bounciness
 Ricochet/Bounce.
PhysicMaterialCombine bounceCombine = PhysicMaterialCombine.Average
 How the bounce should be calculated.
bool useGravity
 Apply such a mysterious force?
bool useAutoRotation
 Automatically rotate along the forward velocity axis.
LayerMask collisionMask = -1
 Only collide with Colliders in these layers.
bool parentOnZeroVelocityHit
 When your bullet technically gets "stuck" in a collider, have it parent to that transform.
float maxDistance
 Max distance this Bullet can travel.
float maxTime
 Max time this Bullet can live.
float destroyDelay
 The delay before this Bullet is destroyed upon reaching the maxDistance or maxTime.

Properties

static int bulletCount [get, set]
 Total amount of Bullets in the scene.
bool isSleeping [get, set]
 Is this Bullet sleeping?
float totalDistance [get, set]
 Total distance traveled.
float totalTime [get, set]
 Total time existed.

Events

Action< BulletHit, float > OnBulletCollided
 Called when a Bullet hits a Collider. The parameters are the BulletHit hit information and the speed/magnitude.
Action< BulletOnBulletSleep
 Called when the bullet goes to sleep. Sleep happens when velocity.sqrMagnitude lower than (Physics.sleepVelocity * 2)
Action< BulletOnBulletAddTotalTime
 Called each FixedUpdate and adds Time.deltaTime onto its totalTime.
Action< BulletOnBulletAddTotalDistance
 Called when moving the Bullet and adds onto its totalDistance.

Detailed Description

Super simple bullet physics.

Note: Can't detect moving colliders if the collider moves past the bullet further than the bullet's raycast range. This can be 'fixed' by making the bullet go faster. The longer the bullet's speed, the longer its raycast ray and the longer its detection range


SendMessage Events

OnBulletCollided(BulletHit hit) - Called on the Bullets GameObject when the Bullet collides
OnBulletSleep(Bullet bullet) - Called on the Bullets GameObject when the Bullet goes to sleep
OnHitByBullet(BulletHit hit) - Called on the Collider (or the Collider's attached Rigidbody if it has one) when the Bullet hits it


Member Function Documentation

void AddForce ( Vector3  force,
ForceMode  forceMode 
)

Add a force to move this Bullet

Parameters:
forcePush power
forceModeForce type
void WakeUp ( )

Stop sleeping.


Member Data Documentation

PhysicMaterialCombine bounceCombine = PhysicMaterialCombine.Average

How the bounce should be calculated.

float bounciness

Ricochet/Bounce.

LayerMask collisionMask = -1

Only collide with Colliders in these layers.

float destroyDelay

The delay before this Bullet is destroyed upon reaching the maxDistance or maxTime.

float drag

Slow-down amount.

Vector3 gravity = Physics.gravity

A mysterious force.

float mass = 1

Weight.

float maxDistance

Max distance this Bullet can travel.

float maxTime

Max time this Bullet can live.

When your bullet technically gets "stuck" in a collider, have it parent to that transform.

Automatically rotate along the forward velocity axis.

bool useGravity

Apply such a mysterious force?

Vector3 velocity

Current movement velocity.


Property Documentation

int bulletCount [static, get, set]

Total amount of Bullets in the scene.

bool isSleeping [get, set]

Is this Bullet sleeping?

float totalDistance [get, set]

Total distance traveled.

float totalTime [get, set]

Total time existed.


Event Documentation

Action<Bullet> OnBulletAddTotalDistance

Called when moving the Bullet and adds onto its totalDistance.

Action<Bullet> OnBulletAddTotalTime

Called each FixedUpdate and adds Time.deltaTime onto its totalTime.

Action<BulletHit, float> OnBulletCollided

Called when a Bullet hits a Collider. The parameters are the BulletHit hit information and the speed/magnitude.

Action<Bullet> OnBulletSleep

Called when the bullet goes to sleep. Sleep happens when velocity.sqrMagnitude lower than (Physics.sleepVelocity * 2)

 All Classes Namespaces Functions Variables Properties Events