/// <summary> /// On Play we trigger the desired wiggles /// </summary> /// <param name="position"></param> /// <param name="attenuation"></param> protected override void CustomPlayFeedback(Vector3 position, float attenuation = 1.0f) { if (Active && (TargetWiggle != null)) { if (WigglePosition) { TargetWiggle.WigglePosition(WigglePositionDuration); } else { TargetWiggle.StopWigglePosition(); } if (WiggleRotation) { TargetWiggle.WiggleRotation(WiggleRotationDuration); } else { TargetWiggle.StopWiggleRotation(); } if (WiggleScale) { TargetWiggle.WiggleScale(WiggleScaleDuration); } else { TargetWiggle.StopWiggleScale(); } } }
/// <summary> /// Shakes the camera for Duration seconds, by the desired amplitude and frequency /// </summary> /// <param name="duration">Duration.</param> /// <param name="amplitude">Amplitude.</param> /// <param name="frequency">Frequency.</param> public virtual void ShakeCamera(float duration, float amplitude, float frequency, float amplitudeX, float amplitudeY, float amplitudeZ, bool useUnscaledTime) { if (Time.time - _shakeStartedTimestamp < CooldownBetweenShakes) { return; } if ((amplitudeX != 0f) || (amplitudeY != 0f) || (amplitudeZ != 0f)) { _wiggle.PositionWiggleProperties.AmplitudeMin.x = -amplitudeX; _wiggle.PositionWiggleProperties.AmplitudeMin.y = -amplitudeY; _wiggle.PositionWiggleProperties.AmplitudeMin.z = -amplitudeZ; _wiggle.PositionWiggleProperties.AmplitudeMax.x = amplitudeX; _wiggle.PositionWiggleProperties.AmplitudeMax.y = amplitudeY; _wiggle.PositionWiggleProperties.AmplitudeMax.z = amplitudeZ; } else { _wiggle.PositionWiggleProperties.AmplitudeMin = Vector3.one * -amplitude; _wiggle.PositionWiggleProperties.AmplitudeMax = Vector3.one * amplitude; } _shakeStartedTimestamp = Time.time; _wiggle.PositionWiggleProperties.UseUnscaledTime = useUnscaledTime; _wiggle.PositionWiggleProperties.FrequencyMin = frequency; _wiggle.PositionWiggleProperties.FrequencyMax = frequency; _wiggle.PositionWiggleProperties.NoiseFrequencyMin = frequency * Vector3.one; _wiggle.PositionWiggleProperties.NoiseFrequencyMax = frequency * Vector3.one; _wiggle.WigglePosition(duration); }
/// <summary> /// Shakes the camera for Duration seconds, by the desired amplitude and frequency /// </summary> /// <param name="duration">Duration.</param> /// <param name="amplitude">Amplitude.</param> /// <param name="frequency">Frequency.</param> public virtual void ShakeCamera(float duration, float amplitude, float frequency) { _wiggle.PositionWiggleProperties.AmplitudeMin = Vector3.one * -amplitude; _wiggle.PositionWiggleProperties.AmplitudeMax = Vector3.one * amplitude; _wiggle.PositionWiggleProperties.FrequencyMin = frequency; _wiggle.PositionWiggleProperties.FrequencyMax = frequency; _wiggle.PositionWiggleProperties.NoiseFrequencyMin = frequency * Vector3.one; _wiggle.PositionWiggleProperties.NoiseFrequencyMax = frequency * Vector3.one; _wiggle.WigglePosition(duration); }
/// <summary> /// On Play we trigger the desired wiggles /// </summary> /// <param name="position"></param> /// <param name="feedbacksIntensity"></param> protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f) { if (Active && (TargetWiggle != null)) { if (WigglePosition) { TargetWiggle.WigglePosition(ApplyTimeMultiplier(WigglePositionDuration)); } if (WiggleRotation) { TargetWiggle.WiggleRotation(ApplyTimeMultiplier(WiggleRotationDuration)); } if (WiggleScale) { TargetWiggle.WiggleScale(ApplyTimeMultiplier(WiggleScaleDuration)); } } }
/// <summary> /// On Play we trigger the desired wiggles /// </summary> /// <param name="position"></param> /// <param name="feedbacksIntensity"></param> protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f) { if (Active && (TargetWiggle != null)) { if (WigglePosition) { TargetWiggle.PositionWiggleProperties.UseUnscaledTime = Timing.TimescaleMode == TimescaleModes.Unscaled; TargetWiggle.WigglePosition(ApplyTimeMultiplier(WigglePositionDuration)); } if (WiggleRotation) { TargetWiggle.RotationWiggleProperties.UseUnscaledTime = Timing.TimescaleMode == TimescaleModes.Unscaled; TargetWiggle.WiggleRotation(ApplyTimeMultiplier(WiggleRotationDuration)); } if (WiggleScale) { TargetWiggle.ScaleWiggleProperties.UseUnscaledTime = Timing.TimescaleMode == TimescaleModes.Unscaled; TargetWiggle.WiggleScale(ApplyTimeMultiplier(WiggleScaleDuration)); } } }
public override void OnInspectorGUI() { serializedObject.Update(); Undo.RecordObject(target, "Modified MMWiggle"); EditorGUILayout.Space(); EditorGUILayout.PropertyField(_updateMode); EditorGUILayout.Space(); MMFeedbackStyling.DrawSplitter(); DrawValueEditor("Position", _positionActive, _positionEditorProperties, _mmWiggle.PositionWiggleProperties.WiggleType); DrawValueEditor("Rotation", _rotationActive, _rotationEditorProperties, _mmWiggle.RotationWiggleProperties.WiggleType); DrawValueEditor("Scale", _scaleActive, _scaleEditorProperties, _mmWiggle.ScaleWiggleProperties.WiggleType); EditorGUILayout.Space(); EditorGUILayout.LabelField("Debug", EditorStyles.boldLabel); EditorGUILayout.PropertyField(_debugWiggleDuration); EditorGUILayout.BeginHorizontal(); { if (GUILayout.Button("Wiggle Position", EditorStyles.miniButtonLeft)) { _mmWiggle.WigglePosition(_debugWiggleDuration.floatValue); } if (GUILayout.Button("Wiggle Rotation", EditorStyles.miniButtonMid)) { _mmWiggle.WiggleRotation(_debugWiggleDuration.floatValue); } if (GUILayout.Button("Wiggle Scale", EditorStyles.miniButtonRight)) { _mmWiggle.WiggleScale(_debugWiggleDuration.floatValue); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); serializedObject.ApplyModifiedProperties(); }
/// <summary> /// On Play we trigger the desired wiggles /// </summary> /// <param name="position"></param> /// <param name="feedbacksIntensity"></param> protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f) { if (!Active || !FeedbackTypeAuthorized || (TargetWiggle == null)) { return; } TargetWiggle.enabled = true; if (WigglePosition) { TargetWiggle.PositionWiggleProperties.UseUnscaledTime = Timing.TimescaleMode == TimescaleModes.Unscaled; TargetWiggle.WigglePosition(ApplyTimeMultiplier(WigglePositionDuration)); } if (WiggleRotation) { TargetWiggle.RotationWiggleProperties.UseUnscaledTime = Timing.TimescaleMode == TimescaleModes.Unscaled; TargetWiggle.WiggleRotation(ApplyTimeMultiplier(WiggleRotationDuration)); } if (WiggleScale) { TargetWiggle.ScaleWiggleProperties.UseUnscaledTime = Timing.TimescaleMode == TimescaleModes.Unscaled; TargetWiggle.WiggleScale(ApplyTimeMultiplier(WiggleScaleDuration)); } }
/// <summary> /// Shakes the camera for Duration seconds, by the desired amplitude and frequency /// </summary> /// <param name="duration">Duration.</param> /// <param name="amplitude">Amplitude.</param> /// <param name="frequency">Frequency.</param> public virtual void ShakeCamera(float duration, float amplitude, float frequency, float amplitudeX, float amplitudeY, float amplitudeZ) { if ((amplitudeX != 0f) || (amplitudeY != 0f) || (amplitudeZ != 0f)) { _wiggle.PositionWiggleProperties.AmplitudeMin.x = -amplitudeX; _wiggle.PositionWiggleProperties.AmplitudeMin.y = -amplitudeY; _wiggle.PositionWiggleProperties.AmplitudeMin.z = -amplitudeZ; _wiggle.PositionWiggleProperties.AmplitudeMax.x = amplitudeX; _wiggle.PositionWiggleProperties.AmplitudeMax.y = amplitudeY; _wiggle.PositionWiggleProperties.AmplitudeMax.z = amplitudeZ; } else { _wiggle.PositionWiggleProperties.AmplitudeMin = Vector3.one * -amplitude; _wiggle.PositionWiggleProperties.AmplitudeMax = Vector3.one * amplitude; } _wiggle.PositionWiggleProperties.FrequencyMin = frequency; _wiggle.PositionWiggleProperties.FrequencyMax = frequency; _wiggle.PositionWiggleProperties.NoiseFrequencyMin = frequency * Vector3.one; _wiggle.PositionWiggleProperties.NoiseFrequencyMax = frequency * Vector3.one; _wiggle.WigglePosition(duration); }