Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How do I stop particles then resume them when the level restarts after I hit an object?

Discussion in 'Scripting' started by Lightninz, Apr 21, 2022.

  1. Lightninz

    Lightninz

    Joined:
    Apr 13, 2022
    Posts:
    3
    Hello, I have a speed particle effect around my screen when I play, but I want it to turn off when I collide with the tag "Obstacle." If anyone can help me, that would be great! here is my code for the collision. When it collides with the object, it goes into the GameManager which restarts my level. I can also add that code if you want.
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class PlayerColission : MonoBehaviour {
    4.    
    5.     public PlayerMovement movement;
    6.  
    7.    
    8.  
    9.     void OnCollisionEnter (Collision collisionInfo)
    10.     {
    11.         if (collisionInfo.collider.tag == "Obstacle")
    12.         {
    13.             movement.enabled = false;
    14.             FindObjectOfType<GameManager>().EndGame();
    15.         }
    16.     }
    17. }
    18.  
     
  2. LilFire

    LilFire

    Joined:
    Jul 11, 2017
    Posts:
    74