- Home /
How to change character when first character dies ?,Change Character Model mid game ?
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.
Answer by theonerm2_unity · Aug 04, 2020 at 12:54 AM
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);
}
}
}
thank you so much for your help. But, my PlayerToSwitchTo is spawning at 0,0,0 and not at the InitialPlayer Position. Can you please help.
Your answer
Follow this Question
Related Questions
how to load character customization in unity free 2 Answers
Why does my character get stuck in T-pose? 0 Answers
Character Customization (Wrestling Game) 1 Answer
How to random generate stat for different characters? 2 Answers
Character Customization 0 Answers