Hi all…
I’m building an explosion and the wreckage fly around… the problem is: I am trying to make the wreckage do damage if hit something…
So… I enable Collision on Shuriken Particle System. But this doesn’t work!!! Here what i’m using:
Hope next update we have shuriken particles working with 2D colliders and emission on X and Y since 2D use only those, we don’t need it to cast particles on Z.
Cool. I’ll try it. but my only problem is the Z emission. Is there any way to make the particles cast always with position of Z = 0 ? Then it would collide. I’m using Birth emission to simulate the smoke of the wreckage.
On Legacy this situation is fixed using X and Y velocity direction greater than 0 and letting Z with 0. but i wouldn’t have birth emission.
Then in hierarchy window drag drop this empty game object over your sprite object (in hierarchy list), now its child of your sprite
Then add collider to that empty game object: Component / Physics / Sphere collider (adjust its size if needed)
then in particle system you have
[×] Collision, and from dropdown under it: “world”
and [×] Send collision message
then can make script attach it to that empty game object:
using UnityEngine;
using System.Collections;
public class GetHit : MonoBehaviour
{
void OnParticleCollision()
{
// send message to parent of this object, call function "WeGotHit"
transform.parent.SendMessage("WeGotHit",SendMessageOptions.DontRequireReceiver);
}
}
then in the parent object (your sprite) put script to it, sendmessage calls this function there:
using UnityEngine;
using System.Collections;
public class YourScript : MonoBehaviour
{
void WeGotHit()
{
Debug.Log ("we got hit");
}
}
My friend, when i drop a sprite in the scene, it becomes a GameObject (no more sprite) so this object will not be visible in the particle system. May I ask you more detail on this?
Parenting pierce of cake, but use this GameObject prefab in the particle system is not possible! the reference of the sprite used in particle differs from the GameObject with parent collider.
Maybe I’m not being clear enought, although I’ve had try everyone to make the particles collide with anythink.