Teleporting 2 objects

I am trying to do this part in a code were 2 objects switch places with each other but I am not sure how to do it. Can you please help ?

1 Answer

1

public Transform myObjectA;
public Transform myObjectB;

private void Start()
{
    Vector3 tempPosition = myObjectA.position;
    myObjectA.position = myObjectB.position;
    myObjectB.position = tempPosition;
}

That’s basic swapping, but if you’re starting out, you should watch some of the tutorial on the Unity learn site. This one seems to incorporate some of the needed aspects and maybe gives you some inspiration: Teleportation Grenades

thank's I am going to try and make it work.

how come you need a extra position (tempPosition) ?