- Home /
Tracking Player x Position for different things to happen not working
Hello! So I'm making an infinite runner and trying to make it so that when the player z position is between certain ranges different things spawn. However, for some reason, only the 1st one triggers, and even weirder, it keeps triggering the 1st one even after the value exceeds the limit. I'm really stumped here so any help would be very much appreciated!
using UnityEngine;
using UnityEngine.SceneManagement;
public class GameManager: MonoBehaviour
{
public Transform player;
void Start()
{
Debug.Log("Working start");
}
void Update()
{
if(player.position.z < 100)
{
Debug.Log("Bool 1st");
}
if (player.position.z >= 100 && player.position.z <= 500)
{
Debug.Log("Bool 2nd");
}
if (player.position.z >= 500 && player.position.z <= 1000)
{
Debug.Log("Bool 3rd");
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Moving player to generated position 2 Answers
How to make on/off-like gui-button? 3 Answers
How can I modify this rotation code to change how far the object rotates? 0 Answers
How do i Update a Transforms Position, and how do i have objects face along a spline?? 1 Answer
Multiple Cars not working 1 Answer