How to create a portal/teleport.

I have a game where you roll a ball around, avoid obstacles, and collect as many yellow cubes in the given time. How do I create a portal so that if a player goes on to a certain spot, they will be teleported to another area in the same scene? I’m fine with either an invisible portal that the player unknowingly goes in or like an actual oval-shaped portal that the player can see and just go through. All answers are appreciated. Thanks in advance!

Make an object that you want to be the portal (can be invisible if you want).

Add a collider to the object so that the ball collides with the object when you want it to be teleported. Then just add a script to the ball.

    void OnCollisionEnter(Collision collision) {

        if(collision.gameobject.name == "invisible portal")
           gameobject.transporm.position = new Vector2( *some position*)

    }

This C# code is untested and this is just one very simple way of making a portal.

@josp101 I tried this code for my game but it’s saing i have a error at void OnCollisionEnter(Collision collision) { and it’s saying it with the void. What should I do?