Script for teleport on collision?

I’m inexperienced with unity, I’ve only made one game that’s just on the border of functional. The scripts I’ve written for this haven’t been functional at all. I can’t find a second question or tutorial that has what I need for the game.
I need a script with two public boxes. The player will collide with an object (the first box that was entered, say a cube or something) and immediately be transported to the coordinates that were entered in the second box.
I’m bad at explaining things. I essentially want -public, object for collision… public, coordinates of appearance-
In C# if you can please, with an explanation.

To detect collisions in script, Unity uses callbacks such as OnCollisionEnter(Collision) and OnTriggerEnter(Collider).

Both your player and the object need to have a Collider on them.

One of the two need to have a Rigidbody. If you don’t want either of them to fall, just set it to isKinematic.

Then, you simply place this snippet into a script on your player:

public GameObject cube2;

void OnCollisionEnter(Collision col) {

    transform.position = col.transform.position;


This will work, but you can also set the Collider on your teleporting cube to “Trigger”, and in the code above, replace OnCollisionEnter(Collision col) with OnTriggerEnter(Collider col). Notice how one takes a Collision, and the other one takes a Collider.

Let me know if you need anything else.

but isn’t OnCollisionEnter in Javascript not C sharp?