playing particle system in Unity

限于喜欢 提交于 2019-12-25 01:08:57

问题


I am using Unity3D to develop for the HTV Vive using SteamVR. I have downloaded an asset from the asset store with explosion effect created using a particle system. I want to play the particle animation when an object is destroyed. Here is the code I am, unsuccessfully, using.

private void OnDestroy() {
    explosion.GetComponent<ParticleSystem>().Play();
}

Explosion is a public variable of type GameObject set from the inspector. I drop the particle system object there.

Why is it not working? anyone a good recommendation on a short tutorial to learn to use (not to create) particle effects?

Thanks


view of the hierarchy

I have tried this with the PS as a child of the target and as an independent object.

view of the inspector (Target)

view of the inspector (particle system)

edit: for some reason, the particle effect is destroyed right after the scene starts.

来源:https://stackoverflow.com/questions/52937448/playing-particle-system-in-unity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!