Integrate Cinemachine and enhance debug capabilities

- Add Cinemachine package (v3.1.4) and configure related components (e.g., CinemachineBrain, CinemachineCamera, CinemachineFollow).
- Update scene with new Cinemachine virtual camera for improved camera behaviors and tracking.
- Extend `DebugUi` to display grounded status and added supporting logic in `TestScript`.
- Refine physics logic in `TestScript` with grounded checks and updated jump action conditions.
- Minor adjustments to Rigidbody angular damping and ForceMode values.
This commit is contained in:
2025-10-13 18:49:31 +02:00
parent 600eb169f6
commit 021d01fbb1
7 changed files with 206 additions and 9 deletions

View File

@@ -21,6 +21,8 @@ public class TestScript : MonoBehaviour
private double _maxDifference = 0;
private bool _grounded = false;
[SerializeField]
private float torqueForce;
@@ -96,11 +98,11 @@ public class TestScript : MonoBehaviour
_smoothX = 0;
}
if (_jumpAction.WasPressedThisFrame()) {
if (_jumpAction.IsPressed() && _grounded) {
_configurableJoint.yDrive = _softJointDrive;
}
if (_jumpAction.WasReleasedThisFrame()) {
if (_jumpAction.WasReleasedThisFrame() && _grounded) {
float t = Mathf.InverseLerp(0.15f, 0.63f, (float)GetDifference()); // gives 0 when 0.63, 1 when 0.15
float forceMultiplier = Mathf.Lerp(30, 5, t);
@@ -117,6 +119,7 @@ public class TestScript : MonoBehaviour
debugUi.UpdateVelocity(_rigidbody.linearVelocity.y.ToString());
debugUi.UpdateText($"Difference: {_maxDifference}");
debugUi.UpdateCurrentText($"Current difference: {GetDifference()}");
debugUi.UpdateGrounded(_grounded ? "Yes" : "No");
}
private void FixedUpdate()
@@ -130,8 +133,10 @@ public class TestScript : MonoBehaviour
if (Physics.Raycast(origin, dir, out var hit, distance)) {
Debug.DrawRay(origin, dir * hit.distance, Color.yellow);
_grounded = true;
} else {
Debug.DrawRay(origin, dir * distance, Color.white);
_grounded = false;
}
}
}