Anybody able to tell me why this code immediately crashes when using a while loop, yet works fine with the if statement?
void Update()
{//Tracks players position. Script not attached to player object
playerXPos = player.transform.position.x;
playerZPos = player.transform.position.z;
while (playerZPos > 0f) {
print(playerZPos);
}
}
The player's position can return to below 0.
↧