Setup Particle Collisions with the Unity Plugin V3

From PopcornFX
Jump to navigation Jump to search
Unity-logo-g.png


Particles can interact with environment in Unity.
You can choose to interact only with static environment and build a "scene mesh" or use raycast for collisions but it will impact performances.

Editor Scene Mesh

To build a scene mesh in Unity's Editor :

  1. Add a PKFxSceneMeshBuilder component to an object in your scene
  2. Expand "Game Objects To Search"
  3. Drag'n'drop game objects with mesh renderers in their hierarchy to be used as scene meshes.
  4. Enter a pathname (relative to pack's root) to save the built scene mesh to.
  5. Click "Build Mesh".
  6. On your camera's PKFxRenderingPlugin component make sure you enable the scene mesh collision and enter the same pathname.

Runtime Scene Mesh

You can also build a scene mesh during runtime. It will create a PKFxRuntimeMeshAsset.

  1. Call PKFxManager.SceneMeshAddMesh() to add a mesh to the scene mesh.
  2. Call PKFxManager.SceneMeshBuild("Meshes/RuntimeScenemesh.pkmm") to build the mesh.
  3. Call PKFxManager.LoadPkmmAsSceneMesh("Meshes/RuntimeScenemesh.pkmm") to load the mesh.

Raycast for collisions

You can enable the raycast for collisions in the PKFxSettings.