menus and settings
This commit is contained in:
@@ -138,7 +138,6 @@ MantleHeightCastStart = 1.5
|
||||
|
||||
[node name="Bobbing" type="Node3D" parent="."]
|
||||
script = ExtResource("10_7wk1w")
|
||||
BobbingAmplitude = 0.0
|
||||
|
||||
[node name="FieldOfView" type="Node3D" parent="."]
|
||||
script = ExtResource("12_m2mxi")
|
||||
@@ -217,6 +216,7 @@ offset_left = 1524.0
|
||||
offset_top = 1.0
|
||||
offset_right = -8.0
|
||||
offset_bottom = 1.0
|
||||
enabled = false
|
||||
initial_node_to_watch = NodePath("../StateChart")
|
||||
|
||||
[node name="UI" type="CanvasLayer" parent="."]
|
||||
|
||||
@@ -21,6 +21,7 @@ public partial class Bobbing: Node3D
|
||||
public float Delta;
|
||||
public bool IsOnFloorCustom;
|
||||
public Vector3 Velocity;
|
||||
public float SettingsMultiplier;
|
||||
}
|
||||
|
||||
private float _bobbingAccumulator; // Constantly increases when player moves in X or/and Z axis
|
||||
@@ -38,8 +39,8 @@ public partial class Bobbing: Node3D
|
||||
// Because both of them are just waves, we will be slide up with y and then slide down with y
|
||||
// creating bobbing effect. The same works for cos. As the _bobbingAccumulator increases the cos decreases and then increases
|
||||
|
||||
newPositionForCamera.Y = Mathf.Sin(_bobbingAccumulator * BobbingFrequency) * BobbingAmplitude;
|
||||
newPositionForCamera.X = Mathf.Cos(_bobbingAccumulator * BobbingFrequency / 2.0f) * BobbingAmplitude;
|
||||
newPositionForCamera.Y = Mathf.Sin(_bobbingAccumulator * BobbingFrequency) * BobbingAmplitude * parameters.SettingsMultiplier;
|
||||
newPositionForCamera.X = Mathf.Cos(_bobbingAccumulator * BobbingFrequency / 2.0f) * BobbingAmplitude * parameters.SettingsMultiplier;
|
||||
|
||||
_camera.Position = newPositionForCamera;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ public partial class FieldOfView: Node3D
|
||||
public float Delta;
|
||||
public float SprintSpeed;
|
||||
public Vector3 Velocity;
|
||||
public float FOVMultiplier;
|
||||
}
|
||||
|
||||
public void PerformFovAdjustment(FovParameters parameters)
|
||||
@@ -33,10 +34,10 @@ public partial class FieldOfView: Node3D
|
||||
0.5f,
|
||||
parameters.SprintSpeed * 2.0f);
|
||||
|
||||
float targetFov = BaseFov + FovChangeFactor * velocityClamped;
|
||||
float targetFov = BaseFov + FovChangeFactor * velocityClamped * parameters.FOVMultiplier;
|
||||
|
||||
if (parameters.IsCrouchingHeight){
|
||||
targetFov = BaseFov - FovChangeFactor * velocityClamped;
|
||||
targetFov = BaseFov - FovChangeFactor * velocityClamped * parameters.FOVMultiplier;
|
||||
}
|
||||
|
||||
_camera.Fov = Mathf.Lerp(_camera.Fov, targetFov, parameters.Delta * FovChangeSpeed);
|
||||
|
||||
@@ -197,9 +197,27 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
private float _playerHeight;
|
||||
private float _playerRadius;
|
||||
|
||||
private float _lookSensitivityMultiplier = 1.0f;
|
||||
private float _headBobbingMultiplier = 1.0f;
|
||||
private float _fovChangeMultiplier = 1.0f;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
var config = new ConfigFile();
|
||||
|
||||
// Load data from a file.
|
||||
Error err = config.Load("user://config.cfg");
|
||||
|
||||
// If the file didn't load, ignore it.
|
||||
if (err != Error.Ok)
|
||||
{
|
||||
throw new Exception("Couldn't load config.cfg");
|
||||
}
|
||||
|
||||
_lookSensitivityMultiplier = (float) config.GetValue("InputSettings", "LookSensitivity", 1.0f);
|
||||
_headBobbingMultiplier = (float) config.GetValue("InputSettings", "HeadBobbingWhileWalking", 1.0f);
|
||||
_fovChangeMultiplier = (float) config.GetValue("InputSettings", "FovChangeWithSpeed", 1.0f);
|
||||
///////////////////////////
|
||||
// Getting components /////
|
||||
///////////////////////////
|
||||
@@ -944,7 +962,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
private void LookAround()
|
||||
{
|
||||
Vector2 inputLookDir = new Vector2(_inputRotateY, _inputRotateFloorplane);
|
||||
HeadSystem.LookAround(inputLookDir);
|
||||
HeadSystem.LookAround(inputLookDir, _lookSensitivityMultiplier);
|
||||
}
|
||||
|
||||
public void MoveOnGround(double delta)
|
||||
@@ -1023,7 +1041,8 @@ public partial class PlayerController : CharacterBody3D
|
||||
{
|
||||
Delta = delta,
|
||||
IsOnFloorCustom = isOnFloorCustom(),
|
||||
Velocity = Velocity
|
||||
Velocity = Velocity,
|
||||
SettingsMultiplier = _headBobbingMultiplier
|
||||
};
|
||||
Bobbing.PerformCameraBobbing(cameraBobbingParams);
|
||||
|
||||
@@ -1032,7 +1051,8 @@ public partial class PlayerController : CharacterBody3D
|
||||
IsCrouchingHeight = CapsuleCollider.IsCrouchingHeight(),
|
||||
Delta = delta,
|
||||
SprintSpeed = WalkSpeed,
|
||||
Velocity = Velocity
|
||||
Velocity = Velocity,
|
||||
FOVMultiplier = _fovChangeMultiplier
|
||||
};
|
||||
FieldOfView.PerformFovAdjustment(fovParams);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user