- Home /
Respawn System not Moving Character
I have a respawn system where the method is being called to respawn but the player position is not being reset. The script is on the player controller, I have searched and looked at various videos but all of their systems don't seem to work so it has to be something I did wrong.
//player attribute variables
public int maxHealth = 100;
public int health;
public GameObject[] spawnPoints;
[SerializeField] GameObject spawnPrefab;
[SerializeField] GameObject playerPos;
private bool gotHit;
private bool respawning;
void Respawn()
{
Debug.Log("Respawning...");
//int randomNum = Random.Range(0, spawnPoints.Length);
health = maxHealth;
//transform.position = spawnPoints[randomNum].transform.position;
playerPos.transform.position = spawnPrefab.transform.position;
}
If as you say the script is on the player object itself that you want to move, you call simply call transform.position = spawnPrefab.transform.position
. And then you need to make sure that the spawnPrefab is at the location you want to move and that the method is indeed being called.
Your answer
![](https://koobas.hobune.stream/wayback/20220612193655im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to create a duplicate of an object after a specific time with the same starting properties? 1 Answer
Problems with respawn and camera disable after instantiation ..? Help please 0 Answers
whats wrong with my enemy respawn script???? 1 Answer
Teleport (Respawn) is Not Working in a 3D Project. 2 Answers