- Home /
Question by
ArnauNaval · Mar 25, 2020 at 10:08 AM ·
vrparticlesystemexplosion
Unity Particle System some explosions loop some others do not
Hey
So I have this VR game where you are supposed to pop balloons, and I wanted to add a Tiny Explosion effect everytime you pop one.
The thing is that sometimes this explosion loops and sometimes it does not, I can't figure what triggers this looping as it is not consistent at all.
In the Inspector loop is set to false and stop action is set to Destroy.
This is the code:
public ParticleSystem explosion;
public bool UpdateMeu()
{
destroyed = false;
float dist = 100f;
Ray raycast = new Ray(transform.position, transform.forward);
RaycastHit hit;
bool bHit = Physics.Raycast(raycast, out hit);
if (interactWithUI != null && interactWithUI.GetState(pose.inputSource))
{
pointer.transform.localScale = new Vector3(thickness * 5f, thickness * 5f, dist);
pointer.GetComponent<MeshRenderer>().material.color = clickColor;
if (hit.collider != null)
{
explosion.loop = false;
Instantiate(explosion, hit.collider.gameObject.transform.position, hit.collider.gameObject.transform.rotation);
Destroy(hit.collider.gameObject);
destroyed = true;
}
}
else
{
pointer.transform.localScale = new Vector3(thickness, thickness, dist);
pointer.GetComponent<MeshRenderer>().material.color = color;
}
pointer.transform.localPosition = new Vector3(0f, 0f, dist / 2f);
return destroyed;
}
Comment