- Home /
My Particles effects are not showing up in my game
Hello! I'm relatively new to Unity and C# so any help would be great! I set up my code and have my particle effect ready but for some reason, it isn't appearing in my game. I'm not sure if it's my code or if it has something to do with my Particle System. It works when I hit play on my particle effect but it doesn't work with the power up script. I was following a tutorial on youtube. When I touch my powerup it just destroys itself and doesn't play the effect. (https://www.youtube.com/watch?v=CLSiRf_OrBk&list=LLuMK-SEXuXBu9PL6A7yNwSg∈dex=2&t=86s)
Can you post a snippet of your code, especially where the particle system is played and destroyed? $$anonymous$$y first guess is that it isn't being told to play in the script. Second guess is that it is starting and then being immediately destroyed. Third guess is the material assigned to the particle system isn't being rendered.
of course! I just followed how the video tutorial was showing but this is how my code looks.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PowerUpPickupEffect : $$anonymous$$onoBehaviour
{
public GameObject pickupEffect;
void OnTriggerEnter2D (Collider2D other)
{
if (other.CompareTag("Player"))
{
Pickup();
}
}
void Pickup()
{
Instantiate(pickupEffect, transform.position, transform.rotation);
Destroy(gameObject);
}
}
Answer by Artik2442 · Jul 22, 2020 at 09:28 AM
Are you using a particle system with auto destroy?
Because if there is this type of script attached to your PS (particle system), that means that it will automatically be destroyed and won't play.
If not, I can't help you, sorry.
Make sure that you haven't done a mistake when following the tutorial.
Answer by alexanderlarsen · Jul 22, 2020 at 10:52 AM
Are you sure you are instantiating the particle effect correctly?
https://docs.unity3d.com/ScriptReference/Object.Instantiate.html