protected override void OnUpdate()
        {
            Entities.ForEach((Entity teleportEntity, ref CurveTeleporterCalculations ctc, ref ParabolPointsParameters ppp, ref ParabolCalculations parabolCalc, ref GeneralTeleportParameters gtp, ref TeleportNavMesh tnm, ref VRRaycastParameters raycastParam) =>
            {
                if (gtp.CurrentTeleportState == ETeleportState.Selecting)
                {
                    NativeArray <Translation> pointsTranslation = new NativeArray <Translation>(ppp.PointCount, Allocator.Temp);
                    Transform controller = parabolCalc.Origin == Core.Controllers.EHand.LEFT ? VRDF_Components.LeftController.transform : VRDF_Components.RightController.transform;

                    // Calculate Parabola Points
                    parabolCalc.Velocity = ParaboleCalculationsHelper.ForceUpdateCurrentAngle(ctc, controller.TransformDirection(ctc.InitialVelocity));
                    parabolCalc.Normal   = ParaboleCalculationsHelper.ParabolaPointsCalculations(ref pointsTranslation, ref ctc, ppp, tnm, controller.position, raycastParam.ExcludedLayer, parabolCalc.Velocity);

                    var index = 0;

                    Entities.WithAll <ParabolPointTag>().ForEach((Entity point, ref Translation translation) =>
                    {
                        if (_entityManager.GetSharedComponentData <ParabolPointParent>(point).TeleporterEntityIndex == teleportEntity.Index)
                        {
                            translation.Value = pointsTranslation[index].Value;
                            index++;
                        }
                    });

                    pointsTranslation.Dispose();
                }
                else if (gtp.CurrentTeleportState == ETeleportState.Teleporting && !gtp.HasTeleported)
                {
                    if (ctc.PointOnNavMesh || ctc.PointOnTeleportableLayer)
                    {
                        if (gtp.IsUsingFadingEffect)
                        {
                            OnFadingOutEndedEvent.Listeners += TeleportUser;
                            _tempPointToGoTo = ctc.PointToGoTo;
                            new StartFadingOutEvent(true);
                        }
                        else
                        {
                            VRDF_Components.SetVRCameraPosition(ctc.PointToGoTo);
                        }
                    }

                    gtp.HasTeleported = true;
                }
            });
        }
示例#2
0
        /// <summary>
        /// Check for each GameObject that the field set in editor is correct, and if not, look for those object using a tag
        /// </summary>
        private void SetVRDFComponents()
        {
            VRDF_Components.CameraRig       = CheckProvidedGameObject(_cameraRig, "RESERVED_CameraRig");
            VRDF_Components.FloorOffset     = CheckProvidedGameObject(_floorOffset, "Floor_Offset");
            VRDF_Components.VRCamera        = CheckProvidedGameObject(_vrCamera, "MainCamera");
            VRDF_Components.LeftController  = CheckProvidedGameObject(_leftController, "RESERVED_LeftController");
            VRDF_Components.RightController = CheckProvidedGameObject(_rightController, "RESERVED_RightController");

            VRDF_Components.SetVRCameraPosition(_cameraRig.transform.position);


            GameObject CheckProvidedGameObject(GameObject toCheck, string tag)
            {
                // We set the references to the Right COntroller
                if (toCheck == null)
                {
                    Debug.LogErrorFormat("<b>[VRDF] :</b> No {0} was references in VRObjectsAuthoring. Trying to fetch it using tag {1}.", toCheck.transform.name, tag, gameObject);
                    toCheck = GameObject.FindGameObjectWithTag(tag);
                }

                return(toCheck);
            }
        }
 private void TeleportUser(OnFadingOutEndedEvent info)
 {
     OnFadingOutEndedEvent.Listeners -= TeleportUser;
     VRDF_Components.SetVRCameraPosition(_tempPointToGoTo);
 }