//pregunta: el Teleportable deberia manejar la teletransportacion? private void Teleport(GameObject teleportable) { if (otherPortal != null) { if (teleportable.GetComponent <Teleportable>().type == "Player") { teleportable.transform.position = PosVectorPortalTransform(teleportable.transform.position, transform, otherPortal.transform); //Debug.Log("Teleportable.transform.position: " + teleportable.transform.position.ToString("F3")); // calcular angulos entre los dos portales es la cantidad a rotar el judador float angleBetweenPortals = otherPortal.transform.rotation.eulerAngles.y - transform.rotation.eulerAngles.y; float absRotation = angleBetweenPortals + teleportable.transform.rotation.eulerAngles.y; // rotar el jugador con ese angulo. Esto no es bueno ya que solo funciona con los portales verticales, y probablemente el FPAIO tampoco funicone con el judador invertido y esta funcionalidad tiene que estar. float lookAngle = teleportable.GetComponent <FirstPersonAIO>().targetAngles.x; teleportable.GetComponent <FirstPersonAIO>().RotateCamera(new Vector2(lookAngle, absRotation), true); // esta fncion seta la orientacion en valor absoluto, no es bueno, queremos que todo sea relativo a los protales } else if (teleportable.GetComponent <Teleportable>().type == "Prop") { //------Teleportar otro objeto que no sea el jugador----- teleportable.transform.position = PosVectorPortalTransform(teleportable.transform.position, transform, otherPortal.transform); teleportable.transform.rotation = RotationRelativeToPortal(teleportable.transform.rotation, transform, otherPortal.transform); //---- conservar las cantidad de movimiento Rigidbody RB = teleportable.GetComponent <Rigidbody>(); RB.velocity = DirVectorPortalTransform(RB.velocity, transform, otherPortal.transform); //---- conservar la cantidad de movmiento angular RB.angularVelocity = DirVectorPortalTransform(RB.angularVelocity, transform, otherPortal.transform); } otherPortalController.AddTraveller(teleportable); } }