Hi, I'm working on a 2D Puzzle game with portals. I need to create portals that can send objects with specific tags through and have them keep there velocety and preferably there rotation. Similar to portals in "Portal". I have figured out a way to make portals in the 3D mode. Here are some code that I'm using for that. Please help me. Code (csharp): public class Portal : MonoBehaviour { public GameObject otherEnd = null; // The other portal public bool isTeleporting = false; void OnTriggerExit(Collider c) { // Checking if the thig that entered can teleport if (c.tag == "Player" || c.tag == "Portabel") { if (!isTeleporting) { otherEnd.GetComponent<Portal>().TeleportTo(c.gameObject); } isTeleporting = false; } } public void TeleportTo(GameObject g) { // Teleporting g.transform.position = transform.position - (transform.up*0.65f); g.rigidbody.velocity = transform.up * g.rigidbody.velocity.magnitude; isTeleporting = true; } }
For starters can change those into 2D versions: http://docs.unity3d.com/Documentation/ScriptReference/Collider2D.OnTriggerExit2D.html http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody2D-velocity.html