Teleporting Character - issue with transform.position in Unity 2018.3

I am having some issues with teleporting my character in Unity 2018.3.7f1. I am using the FPSController, I created a "portal" with a capsule collider that has the "is Trigger" check marked. I also have created an Empty GameObject as a destination for the character to teleport to. I have a script that is below. It is attached to the portal with the capsule collider.

<--->

public Transform warpTarget;

public Transform thePlayer;

void OnTriggerEnter(Collider other){

thePlayer.transform.position = warpTarget.transform.position;

}

I have attached the empty game object to the warpTarget variable in the Inspector window and I attached the FPSController to the thePlayer variable in the Inspector window. It still doesn't work.

I teach a HS game design class and my lab was updated to 2018.3 2 weeks ago. Prior to updating, I had 2018.2 and it worked. It only stopped working after updating to 2018.3.

Does anyone have any work arounds or insight on how to get this to work? Any input is appreciated.

Hard to tell from your question what the actual problem is and what isn’t working.

If you’re using the built-in FPScontroller, you’re using the Character Controller, and the Character Controller has its own internal sense of its position and velocity. I’m not an expert on the inner workings of the character controller, but I know from encountering a similar bug that the character controller doesnt take kindly to being teleported around.

The solution I ended up using was pretty simply to turn the Character Controller off before teleporting, then on after. As simple as:

CharacterController cc = thePlayer.GetComponent<CharacterController>();

cc.enabled = false;
thePlayer.transform.position = warpTarget.transform.position;
cc.enabled = true;

When the Character Controller is re-enabled it should grab whatever position its at and start working from there.

Hope this works for you. This is what I had to do to get teleportation working.

The problem here is that auto sync transforms is disabled in the physics settings, so characterController.Move() won’t necessarily be aware of the new pose as set by the transform unless a FixedUpdate or Physics.Simulate() called happened in-between transform.position and CC.Move().

To fix that, either enable auto sync transforms in the physics settings, or sync manually via Physics.SyncTransforms right before calling Move().

source : Unity Issue Tracker - CharacterController overrides object&#39;s position when teleporting with Transform.Position

it resolved the problem for me !

Try this for TP script:

 Vector3 tpLocation = new Vector3(13f, -12f, 0f); //Or warpTarget.transform.position.

Quaternion startRotation = Quaternion.Euler(Vector3.zero);

void OnTriggerEnter(Collider coll)
{
  if(coll.gameObject.tag == "player")
  {
  thePlayer.transform.SetPositionAndRotation(tpLocation, startRotation);
  }
}

*NOTE, YOU WILL HAVE TO ADD A PLAYER TAG TO YOUR PLAYER OBJECT FOR THIS TO WORK.

There will be a problem created by Vectors