예제 #1
0
        public void TeleportObject(Portal otherPortal, TeleportableObject teleportableObject)
        {
            var portalMatrix   = FromToPortalMatrix(this, otherPortal);
            var portalRotation = FromToPortalRotation(this, otherPortal);

            var objectPosition     = teleportableObject.transform.position;
            var objectRotation     = teleportableObject.transform.rotation;
            var teleportedPosition = portalMatrix.MultiplyPoint(objectPosition);
            var teleportedRotation = portalRotation * objectRotation;

            var localObjectPosition = transform.InverseTransformPoint(objectPosition);

            if (localObjectPosition.z > 0.0f)
            {
                teleportableObject.TeleportReplica(this, teleportedPosition, teleportedRotation);
            }
            else
            {
                teleportableObject.transform.SetPositionAndRotation(teleportedPosition, teleportedRotation);

                var teleportedEvent = new ObjectTeleportedEvent(portalRotation);
                teleportableObject.OnObjectTeleported(teleportedEvent);
            }
        }
예제 #2
0
 public void OnObjectTeleported(ObjectTeleportedEvent teleportedEvent)
 {
     onObjectTeleported?.Invoke(teleportedEvent);
 }
 private void OnObjectTeleported(ObjectTeleportedEvent e)
 {
     m_flyController.Rotate(e.portalRotation);
 }