I’m trying to detect collisions for a flamethrower particle system. The idea is to get the normal of the collision, to instantiate another fire effect in the correct orientation.
I’ve looked around, and this seems to be done like this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FireDamage : MonoBehaviour
{
[SerializeField] private ParticleSystem effect;
private List<ParticleCollisionEvent> collisionEvents;
// Start is called before the first frame update
void Start()
{
collisionEvents = new List<ParticleCollisionEvent>();
}
// Update is called once per frame
void Update()
{
}
private void OnParticleCollision(GameObject other)
{
int num = effect.GetCollisionEvents(other, collisionEvents);
Debug.Log("events" +other.name.ToString()+ ": "+num);
foreach(ParticleCollisionEvent e in collisionEvents)
{
Instantiate(effect, e.intersection, Quaternion.LookRotation(e.normal, Vector3.up));
Debug.Log("Instantiating effect on: " + other.name.ToString() + "at an angle of: " + e.normal.ToString());
}
}
}
Problem is, effect.GetCollisionEvents returns no events, the list is not populated resulting in me not getting the info i want. Any ideas? thx.