Gravity Engine 12.0
Unity Asset for Gravity
Loading...
Searching...
No Matches
NBodyCollision Class Reference

N body collision. Script that is attached to NBody models (i.e. the mesh model that is a child of an NBody object) to handle collisions. Allows a choice of absorb, bounce or explode and adjusts physics as required to conserve momentum. More...

Inheritance diagram for NBodyCollision:

Public Types

enum  CollisionType {
  ABSORB_IMMEDIATE , ABSORB_ENVELOP , EXPLODE , BOUNCE ,
  EXPLODE_OR_BOUNCE
}
 Type of collision response.
 

Public Attributes

CollisionType collisionType = CollisionType.ABSORB_IMMEDIATE
 
int collisionPrecedence = 1
 Precedence of collision script if both bodies have them. Lower takes precedence.
 
GameObject explosionPrefab
 Game object holding the explosion prefab. Must be inactive and have a DustBallFromNBody script.
 
float explodeOrBounceVelocity = 0
 Velocity threshold for explosion if EXPLODE_OR_BOUNCE type.
 
float bounceFactor = 1f
 (For a bounce collision) This factor is applied to determine the recoil velocities. 1 indicates no energy loss in the collision.
 
string collisionLayer = null
 Optional collision layer. If set, require objects to be on this layer for OnTrigger processing.
 

Detailed Description

N body collision. Script that is attached to NBody models (i.e. the mesh model that is a child of an NBody object) to handle collisions. Allows a choice of absorb, bounce or explode and adjusts physics as required to conserve momentum.

NBodyCollision is trigger based so the model game objects MUST:

  • have a Collider attached with IsTrigger true
  • have a RigidBody attached with IsKinematic true and RigidBody mass set to a very small value

Thanks to JAB for the EXPODE_OR_BOUNCE code.


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