protected virtual void Update()
        {
            inputManager.Update(key);

            // Calculate delta
            if (requires == null || requires.gameObject.activeInHierarchy == true || Input.GetMouseButton(1) == true)
            {
                if (Application.isPlaying == true)
                {
                    var delta = inputManager.GetAverageDeltaScaled();

                    pitch -= delta.y * pitchSensitivity;
                    yaw   += delta.x * yawSensitivity;
                }
            }

            pitch = Mathf.Clamp(pitch, pitchMin, pitchMax);

            // Smoothly dampen values
            var factor = P3dHelper.DampenFactor(dampening, Time.deltaTime);

            currentPitch = Mathf.Lerp(currentPitch, pitch, factor);
            currentYaw   = Mathf.Lerp(currentYaw, yaw, factor);

            // Apply new rotation
            transform.localRotation = Quaternion.Euler(currentPitch, currentYaw, 0.0f);
        }
Exemple #2
0
        protected virtual void LateUpdate()
        {
            transform.position += Vector3.down * speed * Time.deltaTime;

            var factor = P3dHelper.DampenFactor(dampening, Time.deltaTime);

            speed = Mathf.Lerp(speed, 0.0f, factor);
        }
Exemple #3
0
        protected virtual void Update()
        {
            var factor   = P3dHelper.DampenFactor(Dampening, Time.deltaTime);
            var newDelta = Vector3.Lerp(remainingDelta, Vector3.zero, factor);

            transform.position += remainingDelta - newDelta;

            remainingDelta = newDelta;
        }
Exemple #4
0
        protected virtual void LateUpdate()
        {
            if (target != null)
            {
                var position = target.TransformPoint(offset);
                var rotation = target.rotation * Quaternion.Euler(tilt);
                var t        = P3dHelper.DampenFactor(dampening, Time.deltaTime);

                transform.position = Vector3.Lerp(transform.position, position, t);
                transform.rotation = Quaternion.Slerp(transform.rotation, rotation, t);
            }
        }
        protected virtual void Update()
        {
            inputManager.Update(key);

            // Calculate delta
            if (CanRotate == true && Application.isPlaying == true)
            {
                var delta = inputManager.GetAverageDeltaScaled(true);

                pitch -= delta.y * pitchSensitivity;
                yaw   += delta.x * yawSensitivity;
            }

            pitch = Mathf.Clamp(pitch, pitchMin, pitchMax);

            // Smoothly dampen values
            var factor = P3dHelper.DampenFactor(dampening, Time.deltaTime);

            currentPitch = Mathf.Lerp(currentPitch, pitch, factor);
            currentYaw   = Mathf.Lerp(currentYaw, yaw, factor);

            // Apply new rotation
            transform.localRotation = Quaternion.Euler(currentPitch, currentYaw, 0.0f);
        }
Exemple #6
0
        public void UpdateGripped(P3dVrManager vrManager)
        {
            // Position?
            var position    = default(Vector3);
            var positionSet = false;

            if (vrManager.TryGetPosition(node, ref position) == true)
            {
                positionSet = true;

                if (vrManager.IsSimulation == true)
                {
                    position += transform.rotation * localOffset;

                    if (vrManager.GetTrigger(node) == true)
                    {
                        position += transform.rotation * simulatedKeyOffset;
                    }
                }

                position += transform.rotation * simulatedOffset;
            }

            // Rotation?
            var rotation    = default(Quaternion);
            var rotationSet = false;

            if (vrManager.TryGetRotation(node, ref rotation) == true)
            {
                rotationSet = true;
            }

            // Transition?
            var dampening = 1.0f;

            if (vrManager.IsSimulation == true)
            {
                dampening = P3dHelper.DampenFactor(simulatedDampening, Time.deltaTime);
            }

            if (positionSet == true)
            {
                transform.position = Vector3.Lerp(transform.position, position, dampening);
            }

            if (rotationSet == true)
            {
                transform.rotation = Quaternion.Slerp(transform.rotation, rotation, dampening);
            }

            // Events?
            if (vrManager.GetTriggerPressed(node) == true)
            {
                if (storeStates == true)
                {
                    P3dStateManager.StoreAllStates();
                }

                if (onTriggerPress != null)
                {
                    onTriggerPress.Invoke();
                }
            }

            if (vrManager.GetTriggerReleased(node) == true)
            {
                if (onTriggerRelease != null)
                {
                    onTriggerRelease.Invoke();
                }
            }

            if (vrManager.GetGripPressed(node) == true)
            {
                if (onGripPress != null)
                {
                    onGripPress.Invoke();
                }
            }

            if (vrManager.GetGripReleased(node) == true)
            {
                if (onGripRelease != null)
                {
                    onGripRelease.Invoke();
                }
            }
        }