Hey,
I am recreating portal in 2D for a small project and the teleportaion works, the only problem is the player teleports tn the other portal and then straight back again, this keeps happening until the game breaks and the player falls through the floor.
Is there a way that I can move the player away from the portal with some speed to stop the constant teleporting from happening?
Would I have to know what wall the portal has been placed on to move the player away from it in the opposite direction?
public class StepThroughPortal : MonoBehaviour {
public GameObject otherPortal;
void OnTriggerEnter2D(Collider2D other){
Debug.Log ("Hit the Portal");
if (other.tag == "Player") {
other.transform.position = otherPortal.transform.position + otherPortal.transform.forward*2;
}
}
}
Any help at all would be greatly apprecitaed
Cheers
Couldn't you simply make the portal colliders smaller? Or spawn the player a little further away from them?
– LazyElephantUhm... but how/why do you intend to add a script that doesn't exist in the first place??? I mean whichever option you choose, you can't add scripts that don't exist...
– troien