Forum rules - please read before posting.

Trigger not working on particle

edited June 2017 in Technical Q&A
Hi again!

I'm trying to make a particle, that when it hits an NPC, a trigger occurs. But when the particle is literally going right through it, nothing happens. I've tried setting it to detect player and that works, but if I set it to detect "set object" and then the particle, or "object with tag", nothing happens? 

Maybe it just won't work on particles? The particle has the particle script itself, a box collider (tried with Is Trigger both checked and unchecked, and without the collider), and it has the constant ID 
Like I said it works with a player so maybe I'm missing something on the particle?

image
image
image
Thanks!

Comments

  • Triggers work by using Unity's own OnTriggerEnter callback, which I don't believe works with particles.  Particles have their own callback for collision: OnParticleCollision.

    A custom script could detect the collision and then run an ActionList by calling its Interact function.
  • Hi,
    I (somehow) managed to make it detect the collision via script, but I'm struggling for it to call an actionlist. 
    I have: using AC; at the top but after that I'm lost..
    I've tried this but I'm getting errors about actList not existing and No overload for runactionlistasset

    image
    I'll be able to do this some day!
  • Without seeing the code and the errors themselves, we can't give any specific help with the script.

    But inside your class you need a public ActionList that gets exposed in the Inspector, e.g:

    public ActionList myActionList;

    And then inside the OnParticleCollision function:

    myActionList.Interact ();
  • Hi Chris,
    That worked, just one issue-- I can only assign the actionlist if the game object is in scene. If I try to assign it in the prefab in the resources/try to save it from the scene to a prefab, it doesn't let me/resets the actionlist field back to 'none'.
  • If you want to reference an ActionList asset instead of a scene-based ActionList, replace "public ActionList" with "public ActionListAsset".
  • Thanks so much Chris, that worked! :)
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.