portal from left screen to right

I wanna make a “portal” like in doodle jump where if the play jump to left of screen he will get out from right of it, and the same right to left

Just check every frame if the player is outside the screen to the left or right, and switch place if needed:

This code would “portal” the player when the player hits the screens’ left/right edges: (JavaScript)

function Update(){

if(player.transform.position.x<0){
    player.transform.position.x=Screen.width 
}else if(player.transform.position.x>Screen.width-playerWidth){
    player.transform.position.x=-playerWidth; //sets the player's right side right at the screen's left side
}

}

Keeping it player.transform.position.x<0 instead of player.transform.position.x<=0 should do so if you only go left, you would portal to the other side and keep going left, without bouncing back to where you portal from, which might happen if it was player.transform.position.x<=0.

Hope this helped.

void Update(){
//get the screen position
Vector3 scrPos = Camera.main.WorldToScreenPoint(transform.position);
//Check if we are too far left
if(scrPos.x < 0) TeleportRight(scrPos);
//check if we are too far right
if(scrPos.x > Screen.width) TeleportLeft(scrPos);
}

//TeleportRight moves character from it's current x position to x position 10 pixels left from the right edge of the screen
void TeleportRight(Vector3 scrPos){
//this is the position on the screen we want to move the character too, we only want to change it's x-coordinate
Vector3 goalScrPos = new Vector3(Screen.width-10, scrPos.y, scrPos.z);
//translate goal screen position to world position
Vector3 targetWorldPos = Camera.main.ScreenToWorldPoint(goalScrPos);
//move player
transform.position = targetWorldPos;
}

Solved in a different discussion.