Okay, I have a player and two portals that use OnTriggerEnter with colliders. The player enters the portal and teleports to the location of the second portal… (it says in the debug.log that I did) but the actual location is wrong… It seems like it gets stuck on a wall when it goes there each time. I’ll explain through screenshots:
This first picture shows the player (a cube) and one of the portals. the two walls that are highlighted(where they intersect) is where my player spawns… Not only does the player spawn, but it keeps walking back to the clicked location (the portal the player just teleported from and enters an infinite loop!)
I included the full level with both portals here (it’s essentially a mirror image):
(here is where it teleports me to every time):
Essentially - is the wall blocking my agent from changing it’s location?
Player Inspector:
Portal Inspector:
Here’s the code I use:
using UnityEngine;
public class PortalScript : MonoBehaviour
{
public GameObject OtherPortal;
void OnTriggerEnter(Collider collider)
{
Debug.Log("made it here:" + collider);
if (collider.tag == "Player")
{
Debug.Log("Player entered the portal");
collider.transform.position = OtherPortal.transform.position;
Debug.Log(collider.transform.position);
collider.transform.Rotate(collider.transform.eulerAngles + 180f * Vector3.up); //should rotate the player 180 degrees
Debug.Log("Player successfully teleported");
}
}
}