All my scripts losts reference to the player on build

Unima9000

New member
I have bunch of scripts in my project. Some of them get reference of the Player prefab object through code on Start or Awake functions, some of them just assigned through inspector.
When i build the game, these references which was assigned though code, stops work for some reason and return all the time just Null (but in the Editor they works just fine).
Is there some sort of initialization rule for UFPS controller for builds, which i miss?
 
Hmm. after quick investigation i find out that somehow that was lines like that, which are broken after build:


Code:
player = GameObject.FindWithTag("Player").GetComponent<UltimateCharacterLocomotion>();

But if i change it like this, everything start to work like it should:
Code:
player = FindObjectOfType<UltimateCharacterLocomotion>();

Is it wrong way to find the Player by a tag in UFPS?
 
I wouldn't use the player tag because finding GameObjects with tags is slow, but that code shouldn't have caused the references to be removed. UFPS does not have any requirements when making the build.
 
Ok, the problem was caused by 2 objects with same tag "Player". Somehow in the editor everything was ok, but in the build was always being picked another, wrong object.
 
Top