Search code examples
c#unity-game-engineparticle-systemunity-webgl

'OnParticleCollision ' does not work in webgl build


using UnityEngine;
using System.Collections;

public class ParticleSystemCollisionManager : MonoBehaviour {

    void OnParticleCollision(GameObject other) {
        // work on pc build, webplayer build
        //when switch to webgl build, it work in editor
        //but after building, run webgl build in browser, it does not work 

        Debug.Log("Collision on " + other.name);
        Destroy(this.gameObject);
    }
}

I build a game TMS

It worked on pc/web playter. And it worked in editor (webgl build setting) too. But after I build it to webgl, it does not work. It seemed that OnParticleCollision does not run.

Do you know the reason? Could you help me fix it?


Solution

  • I got it.

    • Increase the Collision Quality in Collision, and do not forget set the mode to world and 3d.

    enter image description here

    and the reason is here:

    Collision Quality:
    This affects how “watertight” the collisions are - at lower quality levels, particles may sometimes pass through colliders (World mode only).