- Home /
Question by
Micnasr · Apr 30, 2020 at 10:54 AM ·
particlesparticle system
How to play particle with code,How to Play a Particle with code.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class winningplatform : MonoBehaviour
{
int bluecounter = 0;
int pinkcounter = 0;
float timer;
public ParticleSystem WinParticle;
private void Start()
{
}
private void Update()
{
if (bluecounter == pinkcounter && bluecounter > 0) {
timer += Time.deltaTime;
if (timer == 1f)
{
// SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
Debug.Log("Working");
WinParticle.Play();
}
}
}
void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "player1")
{
bluecounter = 1;
Debug.Log("bluewin");
}
else if (collision.gameObject.tag == "player2")
{
pinkcounter = 1;
Debug.Log("pinkwin");
}
}
}
It's not playing, I dont know what I did wrong. I made a prefab of the system and placed it as a child of the parent of the script. I drag and dropped it to the variable too,
Comment