private void DropToNearestFloor(bool withBlink)
        {
            if (enableTeleport && eyeCamera.transform.position.y > this.transform.position.y)
            {
                //send a ray down to find the closest object to stand on
                Ray ray = new Ray(eyeCamera.transform.position, -transform.up);
                RaycastHit rayCollidedWith;
                bool rayHit = Physics.Raycast(ray, out rayCollidedWith);
                float floorY = eyeCamera.transform.position.y - rayCollidedWith.distance;

                if (rayHit && ValidLocation(rayCollidedWith.transform) && !FloorIsGrabbedObject(rayCollidedWith) && (MeshYChanged(rayCollidedWith, floorY) || CurrentFloorChanged(rayCollidedWith)))
                {
                    currentFloor = rayCollidedWith.transform.gameObject;
                    currentRayDownY = floorY;

                    if (withBlink && !rayCollidedWith.transform.GetComponent<MeshCollider>())
                    {
                        Blink(blinkTransitionSpeed);
                    }

                    Vector3 newPosition = new Vector3(this.transform.position.x, floorY, this.transform.position.z);
                    var teleportArgs = new DestinationMarkerEventArgs
                    {
                        destinationPosition = newPosition,
                        distance = rayCollidedWith.distance,
                        enableTeleport = true,
                        target = currentFloor.transform
                    };
                    OnTeleporting(gameObject, teleportArgs);
                    SetNewPosition(newPosition, currentFloor.transform);
                    OnTeleported(gameObject, teleportArgs);
                }
            }
        }
 public virtual void OnDestinationMarkerEnter(DestinationMarkerEventArgs e)
 {
     if (DestinationMarkerEnter != null)
     {
         DestinationMarkerEnter(this, e);
     }
 }
Beispiel #3
0
 private void OnTreeTeleport(object sender, VRTK.DestinationMarkerEventArgs e)
 {
     if (e.target == treeTeleportPoint.transform)
     {
         // Make the cat responsive to items
         cat.EnableReaction();
     }
 }
 protected override void DoTeleport(object sender, DestinationMarkerEventArgs e)
 {
     base.DoTeleport(sender, e);
     if (e.enableTeleport)
     {
         DropToNearestFloor(false, false);
     }
 }
 protected virtual void DoTeleport(object sender, DestinationMarkerEventArgs e)
 {
     if (enableTeleport && ValidLocation(e.target) && e.enableTeleport)
     {
         OnTeleporting(sender, e);
         Vector3 newPosition = GetNewPosition(e.destinationPosition, e.target);
         CalculateBlinkDelay(blinkTransitionSpeed, newPosition);
         Blink(blinkTransitionSpeed);
         SetNewPosition(newPosition, e.target);
         OnTeleported(sender, e);
     }
 }
Beispiel #6
0
 protected virtual void EndTeleport(object sender, DestinationMarkerEventArgs e)
 {
     OnTeleported(sender, e);
 }
Beispiel #7
0
 protected virtual void ProcessOrientation(object sender, DestinationMarkerEventArgs e, Vector3 targetPosition, Quaternion targetRotation)
 {
 }
Beispiel #8
0
 protected virtual void StartTeleport(object sender, DestinationMarkerEventArgs e)
 {
     OnTeleporting(sender, e);
 }
Beispiel #9
0
        /// <summary>
        /// The Teleport/4 method calls the teleport to update position without needing to listen for a Destination Marker event.
        ///  It will build a destination marker out of the provided parameters.
        /// </summary>
        /// <param name="target">The Transform of the destination object.</param>
        /// <param name="destinationPosition">The world position to teleport to.</param>
        /// <param name="destinationRotation">The world rotation to teleport to.</param>
        /// <param name="forceDestinationPosition">If `true` then the given destination position should not be altered by anything consuming the payload.</param>
        public virtual void Teleport(Transform target, Vector3 destinationPosition, Quaternion?destinationRotation = null, bool forceDestinationPosition = false)
        {
            DestinationMarkerEventArgs teleportArgs = BuildTeleportArgs(target, destinationPosition, destinationRotation, forceDestinationPosition);

            Teleport(teleportArgs);
        }
Beispiel #10
0
 /// <summary>
 /// The Teleport/1 method calls the teleport to update position without needing to listen for a Destination Marker event.
 /// </summary>
 /// <param name="teleportArgs">The pseudo Destination Marker event for the teleport action.</param>
 public virtual void Teleport(DestinationMarkerEventArgs teleportArgs)
 {
     DoTeleport(this, teleportArgs);
 }
 private void OnTeleported(object sender, DestinationMarkerEventArgs e)
 {
     if (stayGrabbedOnTeleport && AttachIsTrackObject() && trackPoint)
     {
         transform.position = grabbingObject.transform.position;
     }
 }
 protected override void StartTeleport(object sender, DestinationMarkerEventArgs e)
 {
     base.StartTeleport(sender, e);
 }
 private void OnTeleport(object sender, DestinationMarkerEventArgs e)
 {
     Ungrab(false, e.controllerIndex, e.target.gameObject);
 }
 private void OnTeleport(object sender, DestinationMarkerEventArgs e)
 {
     Ungrab(false, e.controllerIndex, e.target.gameObject);
 }
        private void TeleportFall(bool withBlink, float floorY, RaycastHit rayCollidedWith)
        {
            var floorDelta = currentRayDownY - floorY;
            currentFloor = rayCollidedWith.transform.gameObject;
            currentRayDownY = floorY;
            var newPosition = new Vector3(transform.position.x, floorY, transform.position.z);

            var teleportArgs = new DestinationMarkerEventArgs
            {
                destinationPosition = newPosition,
                distance = rayCollidedWith.distance,
                enableTeleport = true,
                target = currentFloor.transform
            };

            OnTeleporting(gameObject, teleportArgs);
            if (withBlink && (floorDelta > blinkYThreshold || floorDelta < -blinkYThreshold))
            {
                Blink(blinkTransitionSpeed);
            }
            SetNewPosition(newPosition, currentFloor.transform);
            OnTeleported(gameObject, teleportArgs);
        }
 protected override void EndTeleport(object sender, DestinationMarkerEventArgs e)
 {
 }
 protected void OnTeleporting(object sender, DestinationMarkerEventArgs e)
 {
     if (Teleporting != null)
     {
         Teleporting(this, e);
     }
 }
 public virtual void OnDestinationMarkerSet(DestinationMarkerEventArgs e)
 {
     if (DestinationMarkerSet != null)
         DestinationMarkerSet(this, e);
 }
 private void DoPointerDestinationSet(object sender, DestinationMarkerEventArgs e)
 {
     DebugLogger(e.controllerIndex, "POINTER DESTINATION", e.target, e.distance, e.destinationPosition);
 }
 private void OnTeleporting(object sender, DestinationMarkerEventArgs e)
 {
     if (!stayGrabbedOnTeleport)
     {
         ZeroVelocity();
         ForceStopAllInteractions();
     }
 }
Beispiel #21
0
 protected virtual void OnTeleport(object sender, DestinationMarkerEventArgs e)
 {
     Ungrab(false, e.controllerReference, e.target.gameObject);
 }
Beispiel #22
0
 protected override void OnTeleporting(object sender, DestinationMarkerEventArgs e)
 {
     base.OnTeleporting(sender, e);
 }
 void DoPointerOut(object sender, DestinationMarkerEventArgs e)
 {
     DebugLogger(e.controllerIndex, "POINTER OUT", e.target, e.distance, e.destinationPosition);
 }
Beispiel #24
0
 private void OnTeleport(object sender, DestinationMarkerEventArgs e)
 {
     UngrabDisc(false, e.controllerIndex);
 }