just for syncing changes

This commit is contained in:
MrTorex committed 2025-11-10 22:16:36 +03:00
1 parent 0e188efe59
commit f8448ba922
4 files changed
+34 -412

No files matched your search

@@ -17,6 +17,8 @@ namespace Code.Gameplay.Character.Controller.Abilities
private Vector3 _lastWallNormal;
private float _lastWallContactHeight;
private float _leanFactor;
private float _leanSign;
private Vector3 _leanDirection;
public WallLeanMechanic(float maxLeanAngle, float leanSharpness, float heightScale)
{
@@ -32,10 +34,23 @@ namespace Code.Gameplay.Character.Controller.Abilities
}
// Вызывается из OnMovementHit
public void OnWallContact(Vector3 wallNormal, float contactHeight)
public void OnWallContact(KinematicCharacterMotor motor, Vector3 wallNormal, float contactHeight)
{
_lastWallNormal = wallNormal;
_lastWallContactHeight = contactHeight; }
_lastWallContactHeight = contactHeight;
_leanDirection = -_lastWallNormal;
_leanDirection = Vector3.ProjectOnPlane(_leanDirection, motor.CharacterUp).normalized;
_leanSign = Mathf.Sign(_lastWallNormal.x != 0
? Vector3.Dot(_leanDirection, motor.CharacterForward * _lastWallNormal.z)
: Vector3.Dot(_leanDirection, motor.CharacterForward * _lastWallNormal.z));
Debug.Log("CharacterUp: " + motor.CharacterUp);
Debug.Log("CharacterForward: " + motor.CharacterForward);
Debug.Log("CharacterRight: " + motor.CharacterRight);
Debug.Log(_leanSign);
}
// Обновление каждый кадр
public void UpdateLean(KinematicCharacterMotor motor, float deltaTime)
@@ -66,13 +81,12 @@ namespace Code.Gameplay.Character.Controller.Abilities
return;
}
var leanDirection = -_lastWallNormal;
leanDirection = Vector3.ProjectOnPlane(leanDirection, motor.CharacterUp).normalized;
if (leanDirection.sqrMagnitude < 0.01f) return;
var leanAngle = _leanFactor * _maxLeanAngle;
var leanRotation = Quaternion.AngleAxis(leanAngle, Vector3.Cross(motor.CharacterUp, leanDirection));
if (_leanDirection.sqrMagnitude < 0.01f) return;
var leanAngle = _leanSign * _leanFactor * _maxLeanAngle;
var leanRotation = Quaternion.AngleAxis(leanAngle, Vector3.Cross(motor.CharacterUp, _leanDirection));
_characterTransform.localRotation = leanRotation;
}
}
@@ -225,7 +225,7 @@ namespace Code.Gameplay.Character.Controller
var dotWithUp = Vector3.Dot(hitNormal, motor.CharacterUp);
if (Mathf.Abs(dotWithUp) <= _wallClimbMechanic.WallNormalThreshold)
{
_wallLeanMechanic.OnWallContact(hitNormal, motor.TransientPosition.y);
_wallLeanMechanic.OnWallContact(motor, hitNormal, motor.TransientPosition.y);
}
}