groundslide camera setup
This commit is contained in:
@@ -156,6 +156,7 @@ debug_color = Color(0, 0.6, 0.701961, 0.341176)
|
|||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.6, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.6, 0)
|
||||||
CameraInclineAcceleration = 20.0
|
CameraInclineAcceleration = 20.0
|
||||||
GroundedCameraIncline = 3.0
|
GroundedCameraIncline = 3.0
|
||||||
|
SlidingJitterAmplitude = 0.2
|
||||||
|
|
||||||
[node name="MantleSystem" parent="HeadSystem" instance=ExtResource("8_qu4wy")]
|
[node name="MantleSystem" parent="HeadSystem" instance=ExtResource("8_qu4wy")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.6, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.6, 0)
|
||||||
|
|||||||
@@ -793,7 +793,7 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
|
|
||||||
var wallHugContactPoint = _onWallRunning.Active ? _currentWallContactPoint : Vector3.Zero;
|
var wallHugContactPoint = _onWallRunning.Active ? _currentWallContactPoint : Vector3.Zero;
|
||||||
var playerVelocity = GetGlobalMoveInput();
|
var playerVelocity = GetGlobalMoveInput();
|
||||||
HeadSystem.LookAround(delta, inputLookDir, playerVelocity, wallHugContactPoint, lookSensitivity);
|
HeadSystem.LookAround(delta, inputLookDir, playerVelocity, Velocity, wallHugContactPoint, lookSensitivity, isSliding: _groundSliding.Active);
|
||||||
}
|
}
|
||||||
public void RotateWeaponWithPlayer()
|
public void RotateWeaponWithPlayer()
|
||||||
{
|
{
|
||||||
@@ -808,7 +808,7 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
Bobbing.CameraBobbingParams cameraBobbingParams = new Bobbing.CameraBobbingParams
|
Bobbing.CameraBobbingParams cameraBobbingParams = new Bobbing.CameraBobbingParams
|
||||||
{
|
{
|
||||||
Delta = delta,
|
Delta = delta,
|
||||||
IsOnFloorCustom = isOnFloorCustom() || _onWallRunning.Active,
|
IsOnFloorCustom = _grounded.Active || _onWallRunning.Active,
|
||||||
Velocity = Velocity,
|
Velocity = Velocity,
|
||||||
SettingsMultiplier = _headBobbingMultiplier
|
SettingsMultiplier = _headBobbingMultiplier
|
||||||
};
|
};
|
||||||
@@ -1267,7 +1267,8 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
public void OnInputSlideStarted()
|
public void OnInputSlideStarted()
|
||||||
{
|
{
|
||||||
_isSlideInputDown = true;
|
_isSlideInputDown = true;
|
||||||
_playerState.SendEvent("slide");
|
if (Velocity.Length() > WalkSpeed/2f)
|
||||||
|
_playerState.SendEvent("slide");
|
||||||
}
|
}
|
||||||
public void OnInputSlideEnded()
|
public void OnInputSlideEnded()
|
||||||
{
|
{
|
||||||
@@ -1711,14 +1712,13 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
CameraModifications((float) delta);
|
CameraModifications((float) delta);
|
||||||
MoveSlideAndHandleStairs((float) delta);
|
MoveSlideAndHandleStairs((float) delta);
|
||||||
MantleSystem.ProcessMantle(_grounded.Active);
|
MantleSystem.ProcessMantle(_grounded.Active);
|
||||||
|
|
||||||
if (WeaponSystem.InHandState.Active)
|
if (WeaponSystem.InHandState.Active)
|
||||||
RotateWeaponWithPlayer();
|
RotateWeaponWithPlayer();
|
||||||
|
|
||||||
if (WeaponSystem.InHandState.Active && !_aiming.Active && TutorialDone)
|
if (WeaponSystem.InHandState.Active && !_aiming.Active && TutorialDone)
|
||||||
{
|
{
|
||||||
DashIndicatorMesh.Visible = false;
|
DashIndicatorMesh.Visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!WeaponSystem.InHandState.Active && TutorialDone)
|
if (!WeaponSystem.InHandState.Active && TutorialDone)
|
||||||
{
|
{
|
||||||
DashIndicatorMesh.Visible = true;
|
DashIndicatorMesh.Visible = true;
|
||||||
|
|||||||
@@ -22,12 +22,26 @@ public partial class HeadSystem : Node3D
|
|||||||
[Export(PropertyHint.Range, "0,10,0.1,or_greater")]
|
[Export(PropertyHint.Range, "0,10,0.1,or_greater")]
|
||||||
public float GroundedCameraIncline { get; set; } = 5f;
|
public float GroundedCameraIncline { get; set; } = 5f;
|
||||||
|
|
||||||
|
[Export(PropertyHint.Range, "0,2,0.1,or_greater")]
|
||||||
|
public float SlidingCameraHeightOffset { get; set; } = 1.0f;
|
||||||
|
|
||||||
|
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
||||||
|
public float SlidingJitterFrequency { get; set; } = 0.01f;
|
||||||
|
|
||||||
|
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
||||||
|
public float SlidingJitterAmplitude { get; set; } = 0.1f;
|
||||||
|
|
||||||
|
private FastNoiseLite _slidingNoise = new FastNoiseLite();
|
||||||
|
|
||||||
public void Init()
|
public void Init()
|
||||||
{
|
{
|
||||||
Input.SetMouseMode(Input.MouseModeEnum.Captured);
|
Input.SetMouseMode(Input.MouseModeEnum.Captured);
|
||||||
_camera = GetNode<Camera3D>("CameraSmooth/Camera3D");
|
_camera = GetNode<Camera3D>("CameraSmooth/Camera3D");
|
||||||
_cameraAnchor = GetNode<Marker3D>("CameraAnchor");
|
_cameraAnchor = GetNode<Marker3D>("CameraAnchor");
|
||||||
_animationPlayer = GetNode<AnimationPlayer>("AnimationPlayer");
|
_animationPlayer = GetNode<AnimationPlayer>("AnimationPlayer");
|
||||||
|
|
||||||
|
_slidingNoise.NoiseType = FastNoiseLite.NoiseTypeEnum.Perlin;
|
||||||
|
_slidingNoise.SetFrequency(SlidingJitterFrequency);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnMantle()
|
public void OnMantle()
|
||||||
@@ -35,7 +49,7 @@ public partial class HeadSystem : Node3D
|
|||||||
_animationPlayer.Play("mantle");
|
_animationPlayer.Play("mantle");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LookAround(double delta, Vector2 lookDir, Vector3 playerVelocity, Vector3? wallContactPoint = null, float sensitivitMultiplier = 1f)
|
public void LookAround(double delta, Vector2 lookDir, Vector3 playerInput, Vector3 playerVelocity, Vector3? wallContactPoint = null, float sensitivitMultiplier = 1f, bool isSliding = false)
|
||||||
{
|
{
|
||||||
// Horizontal movement of head
|
// Horizontal movement of head
|
||||||
float angleForHorizontalRotation = lookDir.X * LookSensitivity * sensitivitMultiplier;
|
float angleForHorizontalRotation = lookDir.X * LookSensitivity * sensitivitMultiplier;
|
||||||
@@ -46,8 +60,9 @@ public partial class HeadSystem : Node3D
|
|||||||
currentCameraRotation.X += Convert.ToSingle(lookDir.Y * LookSensitivity * sensitivitMultiplier);
|
currentCameraRotation.X += Convert.ToSingle(lookDir.Y * LookSensitivity * sensitivitMultiplier);
|
||||||
currentCameraRotation.X = Mathf.Clamp(currentCameraRotation.X, Mathf.DegToRad(-90f), Mathf.DegToRad(90f));
|
currentCameraRotation.X = Mathf.Clamp(currentCameraRotation.X, Mathf.DegToRad(-90f), Mathf.DegToRad(90f));
|
||||||
|
|
||||||
|
// Camera incline on Wall and more
|
||||||
var isWallRunning = wallContactPoint.HasValue && wallContactPoint.Value.Length() > Mathf.Epsilon;
|
var isWallRunning = wallContactPoint.HasValue && wallContactPoint.Value.Length() > Mathf.Epsilon;
|
||||||
var cameraIncline = 0f;
|
float cameraIncline;
|
||||||
if (isWallRunning)
|
if (isWallRunning)
|
||||||
{
|
{
|
||||||
var directionToWall = (wallContactPoint.Value - GlobalPosition).Normalized();
|
var directionToWall = (wallContactPoint.Value - GlobalPosition).Normalized();
|
||||||
@@ -56,11 +71,23 @@ public partial class HeadSystem : Node3D
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var cameraInclineFactor = ComputeCameraInclineFactor(playerVelocity);
|
var cameraInclineFactor = ComputeCameraInclineFactor(playerInput);
|
||||||
cameraIncline = Mathf.DegToRad(GroundedCameraIncline * cameraInclineFactor * -1.0f);
|
cameraIncline = Mathf.DegToRad(GroundedCameraIncline * cameraInclineFactor * -1.0f);
|
||||||
}
|
}
|
||||||
currentCameraRotation.Z = (float) Mathf.Lerp(currentCameraRotation.Z, cameraIncline, delta * CameraInclineAcceleration);
|
currentCameraRotation.Z = (float) Mathf.Lerp(currentCameraRotation.Z, cameraIncline, delta * CameraInclineAcceleration);
|
||||||
_cameraAnchor.Rotation = currentCameraRotation;
|
_cameraAnchor.Rotation = currentCameraRotation;
|
||||||
|
|
||||||
|
if (isSliding)
|
||||||
|
{
|
||||||
|
_cameraAnchor.Position = Vector3.Down*SlidingCameraHeightOffset;
|
||||||
|
float noise1D = _slidingNoise.GetNoise1D(Time.GetTicksMsec());
|
||||||
|
float noiseAmplitude = SlidingJitterAmplitude*Mathf.Clamp(playerVelocity.Length(), 0f, 1f);
|
||||||
|
_cameraAnchor.Position += Vector3.Up*noise1D*noiseAmplitude;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_cameraAnchor.Position = Vector3.Zero;
|
||||||
|
}
|
||||||
|
|
||||||
_camera.GlobalTransform = _cameraAnchor.GetGlobalTransformInterpolated();
|
_camera.GlobalTransform = _cameraAnchor.GetGlobalTransformInterpolated();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user