Help :\ how to create a corpse???

I am a beginner in unity, and wanted when the enemy was destroyed he created the corpse with variable corpse_type = enemy_type

Code Of Enemy

using UnityEngine;
using System.Collections;

public class Inimigo_script : MonoBehaviour {

    //HP
    public int Health ;
    public GameObject blood;
    public GameObject Corpo ;
    public int enemy_type = Random.Range(0,5);

    void Update(){
        if(Health<=0){
            death();
        }
    }
     
        void death(){
            Instantiate(Corpo,transform.position,transform.rotation);
            Instantiate(blood,transform.position,transform.rotation);
            Destroy(gameObject);
        }
         
    }

Code Of Enemy Corpse

public class Corpse_Script : MonoBehaviour{

    public int corpse_type  ;
    public Animator Animador ;

}

Example
if the enemy variable type is equal to 2
the variable corpse_type will equal 2

This person used a game manager, try using that.

1 Like

You could setup a Dictionary that maps corpse_type to a GameObject, then use it to instantiate the corpses. Following @Lecressman suggestion, this dictionary could be part of a game manager.