一击后粒子系统不会停止

时间:2019-05-25 17:21:05

标签: unity3d

我用枪射击了fps,当我射击时,粒子系统继续播放。我想做手枪射击的效果:

我希望持续时间为0.5秒左右

enter image description here

它只会出现更多,而不会产生一枪的效果,它们只会掉下来,我该怎么办? enter image description here enter image description here

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class SpawnProjectiles : MonoBehaviour
{
    public GameObject firePoint;
    public List<GameObject> vfx = new List<GameObject>();
    private GameObject effectToSpawn;
    public Button button;

    // Start is called before the first frame update
    void Start()
    {
        effectToSpawn = vfx[0];
        button.onClick.AddListener(TaskOnClick);
    }

    // Update is called once per frame
    void Update()
    {
       
        
    }
    void SpawnVFX ()
    {
        GameObject vfx;
        if(firePoint != null)
        {
            vfx = Instantiate(effectToSpawn, firePoint.transform.position, Quaternion.identity); 


        }else
        {
            Debug.Log("NoFirePoint");
        }
    }
    void TaskOnClick()
    {

        SpawnVFX();


    }
}

1 个答案:

答案 0 :(得分:2)

取消选中循环,否则粒子系统将继续发光。