One thing we want to prevent is the player being able to leave the game scene. To do this, we did some simple if-statement checks to make sure the player when crossing into a certain part of the screen, either gets limited as far as movement or warps to another part of the screen.
To create the ship boundary area on the Y-axis, we did the If Statement to check if the player goes beyond -4f to 6f. If they hit that, we want to make sure their new position on update keeps them from going past by locking their Y position to those limits.
To make the player move to the other side of the screen, we do a little smoke and mirrors and when the player hits a certain point on the X-axis, we have them move positions while they still retain their transform.position.y location.
A little reminder — else if is used when the same variable is being tested. else if wouldn’t work when comparing the x to the y, but it works when comparing the x to the x.