Player teleport not working
Hello Everyone I'm new to Unity and i'm trying to create a simple platformer to learn some basics Right now i do have created nice levels with double jumps, skills to spawn cubes to jump again in the air
Then i though that creating a teleporter would be nice. I've set up everything but when i enter the trigger the player is flashed for an instant to the position i want it to be teleported to and then it just comes back to the trigger position This is the code i'm actually using ( every single Debug.Log is working fine )
Inside the trigger
public class Teleporter : MonoBehaviour
{
public GameObject newPosition;
public Player player;
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player"))
{
Debug.Log("Trigger Activated");
Player.Teleport(newPosition.transform, player);
}
}
}
Inside the player
public static void Teleport(Transform newPosition, Player player)
{
//player.TeleportTo(newPosition);
Debug.Log("Teleport Activated");
player.TeleportTo(newPosition);
}
void TeleportTo(Transform newPosition)
{
Debug.Log("Teleport Done");
transform.position = newPosition.position;
}
Comment