I’m making a shooting game in which I want to change the character when my current character dies. I have made till the point where I can shoot and kill my current character. So, can anyone help me with the script on how to change to the 2nd character in mid-game.
Why not just simply have character prefabs and switch between them?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour
{
public bool PlayerDead;//Determine PlayerDead in your health script
public GameObject InitialPlayer;//Drag the initial player into this slot
public GameObject PlayerToSwitchTo;
// Update is called once per frame
void Update()
{
if (PlayerDead)
{
Instantiate(PlayerToSwitchTo, InitialPlayer.transform.position, Quaternion.identity);
Destroy(InitialPlayer);
}
}
}