I need help, please. Working with Prefab.

When I lose my life, On RespawnPoint, my Prefab player is invisible. I can move him but I cant see him.

using System.Collections;
using UnityEngine;

public class GameManager : MonoBehaviour {

public static GameManager GM;

public GameObject prefab;
private GameObject respawnPoint;

public int lives;

void Awake()
{
if (GM == null)
{
GM = this;
DontDestroyOnLoad(gameObject);
}
else
{
Destroy(gameObject);
}
respawnPoint = GameObject.FindGameObjectWithTag(“Respawn”);
}

public IEnumerator Respawn()
{
//do something
lives -= 1;
if (lives < 0)
{
Debug.Log(“here use end screen”);
}
yield return new WaitForSeconds(2f);
if(lives>=0)
Instantiate(prefab, respawnPoint.transform.position, respawnPoint.transform.rotation);
//do something
}
}

Can you see the player object in the hierarchy panel? Maybe your player is simply somewhere different than you think it is. To find out:

  • Pause your game in play mode
  • Select your player object in the hierarchy
  • go to the scene view and press the f key with your mouse cursor over the scene view.

The scene view camera should move to focus on the player object.

If it is where you think it is, look at the inspector and make sure that it’s active and the render is enabled.

1 Like

Please use insert code when posting code on the forums!!!

This is almost unreadable.

Also, this is game design. You need to post in scripts.

Wrong forum. Please review the rules and post in the proper forum.