Example #1
0
        public override void UpdateMovement()
        {
            base.UpdateMovement();

            if (dragMode == DragMode.LockToTrack && track)
            {
                track.UpdateDraggable(this);

                if (_rigidbody.angularVelocity != Vector3.zero || _rigidbody.velocity != Vector3.zero)
                {
                    RunInteraction(true);
                }

                if (IsAutoMoving() && activeAutoMove.CheckForEnd(this))
                {
                    StopAutoMove(true);
                }

                if (collideSound && collideSoundClip && track is DragTrack_Hinge)
                {
                    if (trackValue > 0.05f && trackValue < 0.95f)
                    {
                        canPlayCollideSound = true;
                    }
                    else if ((Mathf.Approximately(trackValue, 0f) || (!onlyPlayLowerCollisionSound && Mathf.Approximately(trackValue, 1f))) && canPlayCollideSound)
                    {
                        canPlayCollideSound = false;
                        collideSound.Play(collideSoundClip, false);
                    }
                }
            }
            else if (isHeld)
            {
                if (dragMode == DragMode.RotateOnly && allowZooming && distanceToCamera > 0f)
                {
                    LimitZoom();
                }
            }

            if (moveSoundClip && moveSound)
            {
                if (dragMode == DragMode.LockToTrack && track != null)
                {
                    PlayMoveSound(track.GetMoveSoundIntensity(this), trackValue);
                }
                else
                {
                    PlayMoveSound(_rigidbody.velocity.magnitude, trackValue);
                }
            }
        }
Example #2
0
        public override void UpdateMovement()
        {
            base.UpdateMovement();
            if (dragMode == DragMode.LockToTrack && track)
            {
                track.UpdateDraggable(this);

                if (UsesRigidbody && (_rigidbody.angularVelocity != Vector3.zero || _rigidbody.velocity != Vector3.zero))
                {
                    RunInteraction(true);
                }

                if (IsAutoMoving())
                {
                    if (activeAutoMove.CheckForEnd(this))
                    {
                        StopAutoMove(true);
                    }
                }
                else if (!UsesRigidbody && dragMode == DragMode.LockToTrack && track)
                {
                    if (IsHeld)
                    {
                        heldIntensity = 1f;
                    }
                    else
                    {
                        if (heldIntensity > 0.01f && trackValue > 0f && trackValue < 1f)
                        {
                            switch (track.dragMovementCalculation)
                            {
                            case DragMovementCalculation.DragVector:
                                track.ApplyDragForce(lastFrameForce * heldIntensity, this);
                                break;

                            case DragMovementCalculation.CursorPosition:
                                if (simulatedMass > 0)
                                {
                                    track.ApplyAutoForce(lastFrameTotalPositionAlong, heldIntensity * speedFactor * 0.02f / simulatedMass, this, false);
                                }
                                break;

                            default:
                                break;
                            }
                        }
                        heldIntensity = Mathf.Lerp(heldIntensity, 0f, Time.deltaTime * simulatedMass);
                    }
                }

                if (collideSound && !track.UsesEndColliders)
                {
                    if (trackValue > 0.03f && trackValue < 0.97f)
                    {
                        canPlayCollideSound = true;
                    }
                    else if ((Mathf.Approximately(trackValue, 0f) || (!onlyPlayLowerCollisionSound && Mathf.Approximately(trackValue, 1f))) && canPlayCollideSound)
                    {
                        canPlayCollideSound = false;
                        collideSound.Play(collideSoundClip, false);
                    }
                }
            }
            else if (isHeld)
            {
                if (dragMode == DragMode.RotateOnly && allowZooming && distanceToCamera > 0f)
                {
                    LimitZoom();
                }
            }

            if (moveSoundClip && moveSound)
            {
                if (dragMode == DragMode.LockToTrack && track)
                {
                    PlayMoveSound(track.GetMoveSoundIntensity(trackValue - lastFrameTrackValue));
                }
                else if (_rigidbody)
                {
                    PlayMoveSound(_rigidbody.velocity.magnitude);
                }
            }

            lastFrameTrackValue = trackValue;
        }