camera incline on wall run and normal run
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 21s
Create tag and build when new code gets to main / Export (push) Successful in 6m17s

This commit is contained in:
2025-12-08 12:23:36 +01:00
parent fabafbb35b
commit 2ff8cc74cc
4 changed files with 62 additions and 10 deletions

View File

@@ -476,6 +476,7 @@ public partial class PlayerController : CharacterBody3D
private Vector3 _wallHugStartLocation = Vector3.Zero;
private Vector3 _wallHugStartNormal = Vector3.Zero;
private Vector3 _wallHugStartProjectedVelocity = Vector3.Zero;
private Vector3 _currentWallContactPoint = Vector3.Zero;
public void OnWallDetected()
{
@@ -491,12 +492,17 @@ public partial class PlayerController : CharacterBody3D
public void OnWallStarted()
{
_wallHugStartNormal = WallHugSystem.WallHugNormal.UnwrapOr(Vector3.Up);
_wallHugStartLocation = WallHugSystem.WallHugLocation.UnwrapOr(Vector3.Zero) + _wallHugStartNormal * _playerRadius;
_currentWallContactPoint = WallHugSystem.WallHugLocation.UnwrapOr(Vector3.Zero);
_wallHugStartLocation = _currentWallContactPoint + _wallHugStartNormal * _playerRadius;
_wallHugStartProjectedVelocity = Velocity.Slide(_wallHugStartNormal);
}
public void OnWallStopped()
{
_wallHugStartLocation = Vector3.Zero;
_currentWallContactPoint = Vector3.Zero;
_wallHugStartNormal = Vector3.Zero;
_wallHugStartProjectedVelocity = Vector3.Zero;
}
public void HandleWallHugging(float delta)
@@ -528,11 +534,10 @@ public partial class PlayerController : CharacterBody3D
Velocity = finalHVel + Vector3.Up*verticalSpeed;
Velocity *= 0.995f;
if (WallRunSnapper.IsColliding())
{
GD.Print((WallRunSnapper.GetCollisionPoint() - WallRunSnapper.GlobalPosition).Length());
}
_currentWallContactPoint = WallHugSystem.WallHugLocation.UnwrapOr(Vector3.Zero);
if (isOnFloorCustom())
_playerState.SendEvent("grounded");
if (!WallHugSystem.IsWallHugging() || Velocity.Length() < WallRunSpeedThreshold)
{
_playerState.SendEvent("start_falling");
@@ -643,9 +648,14 @@ public partial class PlayerController : CharacterBody3D
return _inputMoveKeyboard;
}
public Vector3 GetGlobalMoveInput()
{
return Transform.Basis * HeadSystem.Transform.Basis * GetMoveInput();
}
public Vector3 ComputeHVelocity(float delta, float accelerationFactor, float decelerationFactor, Vector3? direction = null)
{
var dir = direction ?? Transform.Basis * HeadSystem.Transform.Basis * GetMoveInput();
var dir = direction ?? GetGlobalMoveInput();
var acceleration = dir.Length() > 0 ? accelerationFactor : decelerationFactor;
@@ -1096,11 +1106,14 @@ public partial class PlayerController : CharacterBody3D
///////////////////////////
// Stateless logic ////////
///////////////////////////
private void LookAround()
private void LookAround(double delta)
{
Vector2 inputLookDir = new Vector2(_inputRotateY, _inputRotateFloorplane);
var lookSensitivity = _isUsingGamepad ? _lookSensitivityMultiplier : _mouseSensitivityMultiplier;
HeadSystem.LookAround(inputLookDir, lookSensitivity);
var wallHugContactPoint = _onWallRunning.Active ? _currentWallContactPoint : Vector3.Zero;
var playerVelocity = GetGlobalMoveInput();
HeadSystem.LookAround(delta, inputLookDir, playerVelocity, wallHugContactPoint, lookSensitivity);
}
public void MoveOnGround(double delta)
@@ -1239,7 +1252,7 @@ public partial class PlayerController : CharacterBody3D
///////////////////////////
public override void _PhysicsProcess(double delta)
{
LookAround();
LookAround(delta);
CameraModifications((float) delta);
HandleStairs((float) delta);
_plannedMantleLocation = MantleSystem.FindMantleForHeadRotation(HeadSystem.Rotation.Y);