- Home /
Death Particles won't show where player dies.,Particles won't follow the player.
,So I'm working on a 2D platformer, and I got stuck somewhere. I have set up a particle system, one that will show when the player dies and one that will show when the player respawn, the script is EXACTLY as the one in the tutorial that I'm following: https://youtu.be/vwUahWrY9Jg?t=9m42s But my particles won't show on the player when he dies. They will be shown on the default spot that they were created. Like this: http://recordit.co/4C13Wk37uM I already deleted them from there, and I think that the death particle should be attached to the player or something so it can follow the player and play when he dies. And the respawn particle should be attached to the checkpoints. In the video the guy does nothing about that but they work. Any help? Please, I've been struggling on this for a couple of hours and it's already frustrating
The script:
using System.Collections; using UnityEngine;
public class LevelManager : MonoBehaviour {
public GameObject currentCheckpoint;
private PlayerController player;
public GameObject deathParticle;
public GameObject respawnParticle;
// Use this for initialization
void Start () {
player = FindObjectOfType<PlayerController>();
}
// Update is called once per frame
void Update () {
}
public void RespawnPlayer()
{
Instantiate (deathParticle, player.transform.position, player.transform.rotation);
Debug.Log ("Player Respawn");
player.transform.position = currentCheckpoint.transform.position;
Instantiate(respawnParticle, currentCheckpoint.transform.position, currentCheckpoint.transform.rotation);
}
}
Please help me
The thing is you can attach the script to whatever Game object in the scene and it should work. Lets try to troubleshoot 1. Did you make a Prefab of the Deathparticle. 2. Did you drag and drop the Deathparticle prefab on to the Level manager script in the inspector? 3. Dose the script find the player game object(you are not getting Null errors right ?)
You mention " I think that the death particle should be attached to the player or something so it can follow the player and play when he dies" the code dose this for you, Follow the tutorial 100%. If you are still having problems you just got to reset man.
Answer by CoderNation1 · Mar 15, 2018 at 03:10 AM
The reason why you don't see your death particles is that once you die you instantly get reset back to your checkpoint. Basically teleporting. You never get the chance to see the actual particles because the dying and respawning all happens in an instant. I recommend you use a Coroutine so you can see the death particles momentarily then you reset the player. Call the Respawn function all happens in a single cycle with no delay. @edy_sefu41