Skip to content

Instantly share code, notes, and snippets.

@remusjones
Created May 19, 2016 20:45
Show Gist options
  • Select an option

  • Save remusjones/1dfd28f013630a8c32ef1b0a7352fb17 to your computer and use it in GitHub Desktop.

Select an option

Save remusjones/1dfd28f013630a8c32ef1b0a7352fb17 to your computer and use it in GitHub Desktop.
void OnParticleCollision(GameObject other)
{
ParticleSystem.Particle[] particles = new ParticleSystem.Particle[m_hitAnim.particleCount];
m_hitAnim.GetParticles(particles);
ParticleCollisionEvent[] collEvent = new ParticleCollisionEvent[16];
// Keeps track of the amount of collision events
int events = m_hitAnim.GetCollisionEvents(other, collEvent);
for (int i = 0; i < collEvent.Length; i++)
{
Vector3 newIntersect = collEvent[i].intersection;
if (newIntersect != (new Vector3(0, 0, 0))){
Debug.Log("Intestect at\t" + newIntersect);
GameObject obj = Instantiate(Blood, new Vector3(newIntersect.x, 0.1f, newIntersect.z), Blood.transform.rotation) as GameObject;
}
}
m_hitAnim.SetParticles(particles, particles.Length);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment