-
-
Save GarethIW/0d64faec742e49b55e62b51c1235cfb5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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