Quantcast
Channel: Answers for "Unity Creating Invisible Clone (C#)"
Viewing all articles
Browse latest Browse all 12

Answer by Dameon_

$
0
0
I'm not entirely sure if it's a bug, but your implementation seems fine. If Unity really is making a duplicate object, the workaround is to get all the objects with the player tag, and search them for the valid player object. GameObject[] playerList = GameObject.FindGameObjectsWithTag("Player"); // Get a list of all the objets with the player tag into an array for (int i = 0; i < playerList.Length(); i++) { if (playerList[i].GetComponent() != null) // See if we can find the script on the returned object { player = PlayerList[i]; break; } } if (player == null) { // Check to make sure we found the player. Debug.LogError("Unable to find player object!"); return; // Prevent any NullExceptionErrors }

Viewing all articles
Browse latest Browse all 12

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>