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); } } }
/** * Called every frame by StateHandler. */ public override void UpdateMovement() { base.UpdateMovement(); if (dragMode == DragMode.LockToTrack && track) { if (track && (_rigidbody.angularVelocity != Vector3.zero || _rigidbody.velocity != Vector3.zero)) { track.UpdateDraggable(this); if (interactionOnMove && gameObject.layer != LayerMask.NameToLayer(KickStarter.settingsManager.deactivatedLayer)) { if (!KickStarter.actionListManager.IsListRunning(interactionOnMove)) { interactionOnMove.Interact(); } } } else if (targetTrackSpeed > 0f) { trackValue = track.GetDecimalAlong(this); } if (targetTrackSpeed > 0f) { if ((targetTrackValue == 0f && trackValue < 0.01f) || (targetTrackValue == 1f && trackValue > 0.99f)) { // Special case, since colliders cause ends to not quite be met StopAutoMove(); } else if ((targetStartedGreater && targetTrackValue > trackValue) || (!targetStartedGreater && targetTrackValue < trackValue)) { track.ApplyAutoForce(targetTrackValue, targetTrackSpeed, this); } else { StopAutoMove(); } } if (collideSound && collideSoundClip && track is DragTrack_Hinge) { if (trackValue > 0.05f && trackValue < 0.95f) { canPlayCollideSound = true; } else if ((trackValue == 0f || (!onlyPlayLowerCollisionSound && trackValue == 1f)) && canPlayCollideSound) { canPlayCollideSound = false; collideSound.Play(collideSoundClip, false); } } if (targetTrackSpeed == 0f && !isHeld && (trackValue == 0f || trackValue == 1f)) { _rigidbody.isKinematic = true; } else { _rigidbody.isKinematic = false; } } else if (isHeld) { if (dragMode == DragMode.RotateOnly && allowZooming && distanceToCamera > 0f) { LimitZoom(); } } if (moveSoundClip && moveSound) { if (dragMode == DragMode.LockToTrack && track && track is DragTrack_Hinge) { PlayMoveSound(_rigidbody.angularVelocity.magnitude, trackValue); } else { PlayMoveSound(_rigidbody.velocity.magnitude, trackValue); } } }
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; }