Skip to content

Instantly share code, notes, and snippets.

@GarethIW
Last active January 12, 2018 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GarethIW/0d64faec742e49b55e62b51c1235cfb5 to your computer and use it in GitHub Desktop.
Save GarethIW/0d64faec742e49b55e62b51c1235cfb5 to your computer and use it in GitHub Desktop.
// Expose explosion radius in inspector
public float ExplosionRadius;
private void OnTriggerEnter(Collider other)
{
rocketProjectile.velocity = Vector3.zero;
// See if we can find a PicaVoxel Volume object on the thing we just collided with
var volume = other.GetComponentInParent<Volume>();
if(volume!=null)
{
// We found a Volume, so explode!
var batch = volume.Explode(transform.position, ExplosionRadius, 0, Exploder.ExplodeValueFilterOperation.GreaterThanOrEqualTo);
if (batch.Voxels.Count > 0 && VoxelParticleSystem.Instance != null)
{
// Adjust these values to change the speed of the exploding particles
var minExplodeSpeed = 1f;
var maxExplodeSpeed = 2f;
VoxelParticleSystem.Instance.SpawnBatch(batch, pos => (pos - transform.position).normalized * Random.Range(minExplodeSpeed, maxExplodeSpeed));
}
}
Destroy(gameObject);
}
// No longer required
//void DetonateMissile()
//{
// exploder.Explode();
// Destroy(gameObject);
//}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment