Beispiel #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);
            }
        }
 private void Awake()
 {
     m_flyController      = GetComponent <FreeFlyCamera>();
     m_teleportableObject = GetComponent <TeleportableObject>();
 }
Beispiel #3
0
 private void Awake()
 {
     m_teleportableObject = GetComponent <TeleportableObject>();
 }