I need to check for the X axis AND the Y axis at the same time, and maybe chop the else if tree.
public class CameraFollow : MonoBehaviour
{
public Transform Player;
void FixedUpdate ()
{
if (Player.position.x >= 12.1f) {
transform.position = new Vector3(12.1f, Player.position.y, transform.position.z);
}
else if (Player.position.x <= -0.2f) {
transform.position = new Vector3(-0.2f, Player.position.y, transform.position.z);
}
else if (Player.position.y <= -1.18f) {
transform.position = new Vector3(Player.position.x, -1.18f, transform.position.z);
}
else if (Player.position.y >= 4.15f) {
transform.position = new Vector3(Player.position.x, 4.15f, transform.position.z);
}
else {
transform.position = new Vector3(Player.position.x, Player.position.y, transform.position.z);
}
}
}
For example, I need the camera to check if X is greater then a certain number as well as if Y is less then a certain number, and I want that to be better then an if else tree.