protected void FixedUpdate() { if (!_initialized || SuperController.singleton.isLoading) { return; } if (_physicsIteration == 0) { DebugDraw.Clear(); } try { _valuesSource?.Update(); if (!SuperController.singleton.freezeAnimation && _valuesSource != null && _motionTarget != null) { var upValue = UpRangeSlider.val * (_valuesSource.GetValue(DeviceAxis.L0) - DeviceAxis.DefaultValue(DeviceAxis.L0)) * 2; var rightValue = RightRangeSlider.val * (_valuesSource.GetValue(DeviceAxis.L1) - DeviceAxis.DefaultValue(DeviceAxis.L1)) * 2; var forwardValue = ForwardRangeSlider.val * (_valuesSource.GetValue(DeviceAxis.L2) - DeviceAxis.DefaultValue(DeviceAxis.L2)) * 2; var yawValue = YawRangeSlider.val * (_valuesSource.GetValue(DeviceAxis.R0) - DeviceAxis.DefaultValue(DeviceAxis.R0)) * 2; var rollValue = RollRangeSlider.val * (_valuesSource.GetValue(DeviceAxis.R1) - DeviceAxis.DefaultValue(DeviceAxis.R1)) * 2; var pitchValue = PitchRangeSlider.val * (_valuesSource.GetValue(DeviceAxis.R2) - DeviceAxis.DefaultValue(DeviceAxis.R2)) * 2; var newUp = Vector3.zero; if (UpDirectionChooser.val == "+Up") { newUp = Vector3.up; } else if (UpDirectionChooser.val == "+Right") { newUp = Vector3.right; } else if (UpDirectionChooser.val == "+Forward") { newUp = Vector3.forward; } else if (UpDirectionChooser.val == "-Up") { newUp = -Vector3.up; } else if (UpDirectionChooser.val == "-Right") { newUp = -Vector3.right; } else if (UpDirectionChooser.val == "-Forward") { newUp = -Vector3.forward; } var coordinatesRotation = Quaternion.FromToRotation(Vector3.up, newUp); var rotation = Quaternion.Euler(coordinatesRotation * new Vector3(pitchValue, yawValue, rollValue)); var offset = coordinatesRotation * new Vector3(rightValue, upValue, forwardValue); _motionTarget?.Apply(offset, rotation); } } catch (Exception e) { SuperController.LogError("Exception caught: " + e); } if (_physicsIteration == 0) { DebugDraw.Enabled = false; } _physicsIteration++; }
protected AbstractValuesSource() { Values = DeviceAxis.Values.ToDictionary(a => a, a => DeviceAxis.DefaultValue(a)); }