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

Need Guidance for Hero dead scene particle effect Play

Discussion in 'General Discussion' started by Abhijit-Mukherjee, Jan 24, 2015.

  1. Abhijit-Mukherjee

    Abhijit-Mukherjee

    Joined:
    Jan 9, 2015
    Posts:
    193
    Hi Buddy ,
    I am stuck in one section of my game ,
    I want to show some pertical effect which I have already created while my hero dead .

    I am calling destroy (hero) method before than I am instantiating the partial then I am calling Application.Loadlabel(0).

    But the problem I am facing is , my partial effect is not visible to me

    Please Find My Code Below

    public void Explode()
    {

    //Instantiate our one-off particle system
    ParticleSystem explosionEffect = Instantiate(DestructionEffect) as ParticleSystem;
    explosionEffect.transform.position = transform.position;
    var cameraTransform = Camera.main.transform;
    // make it a child of the current object
    Transform trns = transform;
    trns.position = new Vector3 (transform.position.x,3.314256f, -0.008056641f);
    cameraTransform.parent = trns ;
    // place it behind the current object
    cameraTransform.localPosition = -Vector3.forward * 5;



    cameraTransform.parent = null;
    // make it point towards the object
    cameraTransform.LookAt(trns);

    //it would play a second time.
    Destroy(explosionEffect.gameObject, 1.0f);


    audioSourceDestroy.PlayOneShot(destroy,20.0f);

    //destroy our game object
    Destroy(playerObject.GetComponent<SpriteRenderer>());

    Application. LoadLabel(0);
    }
    Please guide me .
     
    Last edited: Jan 24, 2015
  2. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,804
  3. Abhijit-Mukherjee

    Abhijit-Mukherjee

    Joined:
    Jan 9, 2015
    Posts:
    193
    hey Ostwind thank you buddy ..
     
  4. Abhijit-Mukherjee

    Abhijit-Mukherjee

    Joined:
    Jan 9, 2015
    Posts:
    193
    Still have no luck !! :(
     
  5. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,804
    Application.LoadLevel ?
     
  6. Abhijit-Mukherjee

    Abhijit-Mukherjee

    Joined:
    Jan 9, 2015
    Posts:
    193
    Application.LoadLevel(1); is a function to load a scene base on scene number ..
     
  7. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,804
    yes but your first post 2 times: Application. LoadLabel(0);
     
  8. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    You can also load level by string lol.

    Application.LoadLevel("NameOfLevel");
     
  9. Abhijit-Mukherjee

    Abhijit-Mukherjee

    Joined:
    Jan 9, 2015
    Posts:
    193
    i have only one Application. LoadLabel(0) .. please ignore the other only one i have
     
  10. Abhijit-Mukherjee

    Abhijit-Mukherjee

    Joined:
    Jan 9, 2015
    Posts:
    193
    ParticleSystem explosionEffect = Instantiate(DestructionEffect) as ParticleSystem; is not visible to me when my hero dead ... it immediate redirect to my scene 0
     
  11. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,804
    did you use DontDestroyOnLoad?

    DontDestroyOnLoad(explosionEffect);

    also why are you instantly loading level if you want to show him dead for a while
     
  12. Abhijit-Mukherjee

    Abhijit-Mukherjee

    Joined:
    Jan 9, 2015
    Posts:
    193
    "why are you instantly loading level if you want to show him dead for a while" Because I want to reload my scene once my hero dead ..
     
  13. Abhijit-Mukherjee

    Abhijit-Mukherjee

    Joined:
    Jan 9, 2015
    Posts:
    193
    How can i wait for a while ?
     
  14. Abhijit-Mukherjee

    Abhijit-Mukherjee

    Joined:
    Jan 9, 2015
    Posts:
    193
    DontDestroyOnLoad(explosionEffect) which script I should attach this .
     
  15. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,804
  16. Abhijit-Mukherjee

    Abhijit-Mukherjee

    Joined:
    Jan 9, 2015
    Posts:
    193
    let me try this buddy ...
     
  17. Abhijit-Mukherjee

    Abhijit-Mukherjee

    Joined:
    Jan 9, 2015
    Posts:
    193