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

Explosion from N body. Generates the particle positions/velocities for an "ejection cone" of debris when NBody objects collide. More...

Inheritance diagram for ExplosionFromNBody:
IGravityParticlesInit

Public Member Functions

void Init (NBody fromNbody, Vector3 contactPoint)
 
void InitNewParticles (int fromParticle, int toParticle, ref double[,] r, ref double[,] v)
 Provide the initial positions and velocity for a range of particles. This method will be called as particles are created by the particle system. The implementing class must fill in the r[,] and v[,] arrays for the range specified. These arrays are indexed by [particle_num, dimension] where dimension 0,1,2 correspond to x,y,z.
 
void InitNewParticles (int fromParticle, int toParticle, ref double[,] r, ref double[,] v)
 Provide the initial positions and velocity for a range of particles. This method will be called as particles are created by the particle system. The implementing class must fill in the r[,] and v[,] arrays for the range specified. These arrays are indexed by [particle_num, dimension] where dimension 0,1,2 correspond to x,y,z.
 

Public Attributes

float coneWidth = 30f
 Cone width (half-angle in degrees from cone axis)
 
float explosionSize = 20f
 Size of the explosion (will control initial velocity based on mass of source NBody object)
 
float velocitySpread = 0
 Range of values in particle velocity.
 
float soften = 1.0f
 Velocity distribution factor (standard deviation of Gaussian)
 

Detailed Description

Explosion from N body. Generates the particle positions/velocities for an "ejection cone" of debris when NBody objects collide.

This script is typically part of an explosion prefab object (with a GravityParticles component) that is then referenced by an NBodyCollision object. The NBodyCollision component will initialize via calling Init() and then the particles will be created according to the inspector parameters.

Member Function Documentation

◆ InitNewParticles()

void ExplosionFromNBody.InitNewParticles ( int  fromParticle,
int  toParticle,
ref double  r[,],
ref double  v[,] 
)

Provide the initial positions and velocity for a range of particles. This method will be called as particles are created by the particle system. The implementing class must fill in the r[,] and v[,] arrays for the range specified. These arrays are indexed by [particle_num, dimension] where dimension 0,1,2 correspond to x,y,z.

See the DustBox script for a sample usage of this interface.

Parameters
fromParticleFrom particle number.
toParticleTo particle number.
r(out) 2D array [numParticles, 3] to hold physics position (x,y,z) per particle
v(out) 2D array [numParticles, 3] to hold velocity (x,y,z) per particle

Implements IGravityParticlesInit.


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