I have a player that is spawned into the game on start, and the “GameObject.FindWithTag(“Player”).transform;” is supposed to find it. The script only seems to update if I have the gameobject with the script for this selected in the hierarchy, otherwise it seems to not be able to find the player.
The spawned(or cloned) player most certainly has the player tag, i’m currently at a loss as to why it can’t be found.
When the gameobject is selected it does show that the cloned player is there. This script works perfectly fine if the player doesn’t need to be spawned in, but it does in my case.
public Transform Player
{
get
{
return _player;
}
set
{
_player = GameObject.FindWithTag("Player").transform;
if (_player != null)
{
playerCharacterController = _player.GetComponent<CharacterController>();
}
else
{
playerCharacterController = null;
}
}
}