Question by
Darmikecnho · Oct 22, 2020 at 09:16 PM ·
2dparticlesystemparticle system
My particale system won't play and I do not know why.
I am trying to get my enemy to shoot every blank amount of time and from what I can tell it should be working but the particle system never goes off. All the debugs in the code go off
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyIO : MonoBehaviour
{
[SerializeField] ParticleSystem Bullet;
public Transform Ttarget;
private float BulletTimer;
private bool hasFired;
// Start is called before the first frame update
void Start()
{
hasFired = false;
BulletTimer = 3;
Bullet = GetComponentInChildren<ParticleSystem>();
}
// Update is called once per frame
void Update()
{
gameObject.transform.rotation = Ttarget.transform.rotation;
BulletTimer -= .01f;
FireBullet();
Debug.Log(BulletTimer);
}
private void FireBullet()
{
if (BulletTimer <= 0)
{
Bullet.Play();
BulletTimer = 3;
hasFired = true;
Debug.Log("fired");
}
else if (hasFired == true && Bullet.IsAlive(false))
{
Debug.Log("stopped");
Bullet.Pause();
hasFired = false;
}
}
}
Comment
Your answer
Follow this Question
Related Questions
"Spherize" rotation of particles 1 Answer
Particles disappear when the parent rotates,My particles disappear when the parent rotates 0 Answers
Is it Possible to use visual effect graph with LWRP configured with 2D renderer 2 Answers
Having Player light torches Using Particle System and OnCollisionEnter? 1 Answer