i have a script in the script if a cube moves to far from the player he comes back but the opposite sides are not working
if( Mathf.Abs(player.position.x - transform.position.x) > 8 )
{
transform.position.x -=1 *Time.deltaTime*8;
print("bigger then x");
}
if( Mathf.Abs(player.position.x - transform.position.x) < -8 )
{
transform.position.x +=1 *Time.deltaTime*8;
print("smaller then x");
}
if( Mathf.Abs(player.position.z - transform.position.z) > 8 )
{
transform.position.z -=1 *Time.deltaTime*8;
print("bigger then z");
}
if( Mathf.Abs(player.position.z - transform.position.z) < -8 )
{
transform.position.z +=10 *Time.deltaTime*8;
print("smallls");
}
it actually gives me bigger then x when i try to go in the - side like -x