I have used this code to keep my actor within the edge of a rectangle with the middle cut out. However, when I move into 3 of the sides, instead of just preventing it to move it spawns it into another corner. The first statement is working fine for the bottom left corner, it is all the others that do not do as they should.
if(getX() <= 47 || getY() >= 466)
{
setLocation(48, 465);
}
if(getX() <= 47 || getY() <= 47)
{
setLocation(48, 48);
}
if(getX() >= 977 || getY() <= 47)
{
setLocation(976, 48);
}
if(getX() >= 977 || getY() >= 466)
{
setLocation(976, 465);
}