0
votes

I have been trying to fix this bug and its driving me nuts only the other Fixes I have checked say that you may have out something static I checked multiple times and I am 99% sure I do not have the problem with it being static this is the script I have beenb having Problems with

  private void Update() {
    if (Vector3.Distance(player.FindGameObjectWithTag("Tag").transform.position, lastEndPosition) < PLAYER_DISTANCE_SPAWN_LEVEL_PART) {
        SpawnLevelPart();
    }
}
1
As your title says. Its GameObject not player. Its a method of the class not the instanceBugFinder

1 Answers

0
votes

Rather than the problem being that you have something that's static, the problem in this case is that you need to be using the static method GameObject.FindGameObjectWithTag() rather than trying to access it from player which is an instance of GameObject.

  private void Update() {
    if (Vector3.Distance(GameObject.FindGameObjectWithTag("Tag").transform.position, lastEndPosition) < PLAYER_DISTANCE_SPAWN_LEVEL_PART) {
        SpawnLevelPart();
    }
}