trying to figure out a camera stutter bug

This commit is contained in:
2025-09-15 16:24:51 +02:00
parent d8ff9c0964
commit 735e128a95
5 changed files with 30 additions and 28 deletions

View File

@@ -54,8 +54,7 @@ namespace RebootReality.jelycho.Player {
} }
void Awake() { void Awake() {
m_NoiseComponent = m_NoiseComponent = Camera.GetCinemachineComponent(CinemachineCore.Stage.Noise) as CinemachineBasicMultiChannelPerlin;
Camera.GetCinemachineComponent(CinemachineCore.Stage.Noise) as CinemachineBasicMultiChannelPerlin;
Assert.IsNotNull(m_NoiseComponent); Assert.IsNotNull(m_NoiseComponent);
SetBobbing(0.0f); SetBobbing(0.0f);

View File

@@ -433,7 +433,7 @@ namespace RebootReality.jelycho.Player {
InterpolateActorState(deltaTime); InterpolateActorState(deltaTime);
} }
TickCharacterRotation(); TickCharacterRotation(deltaTime);
} }
protected override void OnActorCommandServer(ulong senderID, ActorCommand actorCommand) { protected override void OnActorCommandServer(ulong senderID, ActorCommand actorCommand) {
@@ -638,12 +638,13 @@ namespace RebootReality.jelycho.Player {
m_CurrentCameraBobbing = Mathf.MoveTowards(m_CurrentCameraBobbing, m_CurrentCameraBobbing = Mathf.MoveTowards(m_CurrentCameraBobbing,
m_TargetCameraBobbing, m_TargetCameraBobbing,
m_CameraBobbingTransitionSpeed * deltaTime); m_CameraBobbingTransitionSpeed * deltaTime);
m_Camera.SetBobbing(m_CurrentCameraBobbing); // m_Camera.SetBobbing(m_CurrentCameraBobbing);
m_Camera.SetBobbing(0.0f);
m_CameraSpring.UpdateSpring(deltaTime, // m_CameraSpring.UpdateSpring(deltaTime,
m_CharacterForwardTransform.up, // m_CharacterForwardTransform.up,
m_CharacterForwardTransform.right, // m_CharacterForwardTransform.right,
m_CharacterForwardTransform.forward); // m_CharacterForwardTransform.forward);
} }
void SenseInteractable() { void SenseInteractable() {
@@ -823,7 +824,7 @@ namespace RebootReality.jelycho.Player {
// //
// @MARK: Common // @MARK: Common
// //
void TickCharacterRotation() { void TickCharacterRotation(float dt) {
float angleDeg = Mathf.DeltaAngle(m_Camera.Yaw, m_Locomotion.YawRotation); float angleDeg = Mathf.DeltaAngle(m_Camera.Yaw, m_Locomotion.YawRotation);
bool rotateCharacter = false; bool rotateCharacter = false;
@@ -846,12 +847,13 @@ namespace RebootReality.jelycho.Player {
} }
if (rotateCharacter) { if (rotateCharacter) {
m_CharacterTurnVelocity = rotateCharacterSpeed * Time.deltaTime; m_CharacterTurnVelocity = rotateCharacterSpeed * dt;
m_CharacterTurnVelocitySmooth = m_CharacterTurnVelocity; m_CharacterTurnVelocitySmooth = m_CharacterTurnVelocity;
m_Locomotion.YawRotation = Mathf.MoveTowardsAngle(m_Locomotion.YawRotation, float newYaw = Mathf.MoveTowardsAngle(m_Locomotion.YawRotation,
m_Camera.Yaw, m_Camera.Yaw,
m_CharacterTurnVelocity); m_CharacterTurnVelocity);
m_Locomotion.YawRotation = newYaw;
} }
// Aim Target adjustment // Aim Target adjustment
@@ -864,7 +866,7 @@ namespace RebootReality.jelycho.Player {
public bool TryGetBeaconPosition(out Vector3 position) { public bool TryGetBeaconPosition(out Vector3 position) {
var ray = new Ray(m_Camera.Camera.transform.position, var ray = new Ray(m_Camera.Camera.transform.position,
m_Camera.Camera.transform.forward); m_Camera.Camera.transform.forward);
if (Physics.Raycast(ray, out RaycastHit hit, m_BeaconPlacementMaxDistance, m_BeaconPlacementLayerMask) && if (Physics.Raycast(ray, out RaycastHit hit, m_BeaconPlacementMaxDistance, m_BeaconPlacementLayerMask) &&
Vector3.Dot(hit.normal, Vector3.up) >= m_NormalDotUpThreshold) { Vector3.Dot(hit.normal, Vector3.up) >= m_NormalDotUpThreshold) {
position = hit.point; position = hit.point;

View File

@@ -97,13 +97,13 @@ namespace RebootReality.jelycho.Player {
public IPlayable Build(PlayableGraph graph) { public IPlayable Build(PlayableGraph graph) {
m_Mixer = AnimationMixerPlayable.Create(graph, 7); m_Mixer = AnimationMixerPlayable.Create(graph, 7);
AnimationClipPlayable idlePlayable = AnimationClipPlayable.Create(graph, m_IdleClip); var idlePlayable = AnimationClipPlayable.Create(graph, m_IdleClip);
AnimationClipPlayable runForwardPlayable = AnimationClipPlayable.Create(graph, m_RunForwardClip); var runForwardPlayable = AnimationClipPlayable.Create(graph, m_RunForwardClip);
AnimationClipPlayable runBackwardsPlayable = AnimationClipPlayable.Create(graph, m_RunBackwardsClip); var runBackwardsPlayable = AnimationClipPlayable.Create(graph, m_RunBackwardsClip);
AnimationClipPlayable strafeRightPlayable = AnimationClipPlayable.Create(graph, m_StrafeRightClip); var strafeRightPlayable = AnimationClipPlayable.Create(graph, m_StrafeRightClip);
AnimationClipPlayable strafeLeftPlayable = AnimationClipPlayable.Create(graph, m_StrafeLeftClip); var strafeLeftPlayable = AnimationClipPlayable.Create(graph, m_StrafeLeftClip);
AnimationClipPlayable turnRightPlayable = AnimationClipPlayable.Create(graph, m_TurnRightClip); var turnRightPlayable = AnimationClipPlayable.Create(graph, m_TurnRightClip);
AnimationClipPlayable turnLeftPlayable = AnimationClipPlayable.Create(graph, m_TurnLeftClip); var turnLeftPlayable = AnimationClipPlayable.Create(graph, m_TurnLeftClip);
m_Mixer.ConnectInput(0, idlePlayable, 0, 1.0f); m_Mixer.ConnectInput(0, idlePlayable, 0, 1.0f);
m_Mixer.ConnectInput(1, runForwardPlayable, 0, 0.0f); m_Mixer.ConnectInput(1, runForwardPlayable, 0, 0.0f);
@@ -305,12 +305,10 @@ namespace RebootReality.jelycho.Player {
m_Hands.OnCharged += () => { onChargeReady?.Invoke(); }; m_Hands.OnCharged += () => { onChargeReady?.Invoke(); };
m_QuickKickNode = m_ReAnimator.FindNode<AnimationClipNode>("legs_kick_quick"); m_QuickKickNode = m_ReAnimator.FindNode<AnimationClipNode>("legs_kick_quick");
m_IsReady = true; m_IsReady = true;
} }
void Update() { }
public void SetLocomotionParams(PlayerLocomotionAnimatorParams locomotionParams) { public void SetLocomotionParams(PlayerLocomotionAnimatorParams locomotionParams) {
if (!m_IsReady) { if (!m_IsReady) {
return; return;
@@ -318,8 +316,8 @@ namespace RebootReality.jelycho.Player {
m_LegsLayerMixer.SetLayerWeight(1, locomotionParams.IsGrounded ? 0.0f : 1.0f); m_LegsLayerMixer.SetLayerWeight(1, locomotionParams.IsGrounded ? 0.0f : 1.0f);
float2 groundBlendDirection = new float2(locomotionParams.VelocityRightNormalized, var groundBlendDirection = new float2(locomotionParams.VelocityRightNormalized,
locomotionParams.VelocityForwardNormalized); locomotionParams.VelocityForwardNormalized);
m_GroundBlendTree.SetInput(groundBlendDirection, locomotionParams.TurnVelocity); m_GroundBlendTree.SetInput(groundBlendDirection, locomotionParams.TurnVelocity);
} }

View File

@@ -19,7 +19,8 @@
"GUID:15fc0a57446b3144c949da3e2b9737a9", "GUID:15fc0a57446b3144c949da3e2b9737a9",
"GUID:6fa512e17c315dd428ad692183dd0e8c", "GUID:6fa512e17c315dd428ad692183dd0e8c",
"GUID:f2be1b7392ef6cc4eafd0ee8ac7a090a", "GUID:f2be1b7392ef6cc4eafd0ee8ac7a090a",
"GUID:f0ca7da2c713f5849a8e3326866a5e49" "GUID:f0ca7da2c713f5849a8e3326866a5e49",
"GUID:7f7d1af65c2641843945d409d28f2e20"
], ],
"includePlatforms": [], "includePlatforms": [],
"excludePlatforms": [], "excludePlatforms": [],

View File

@@ -772,6 +772,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 00a9f9c2ce4a41fdaadcfb24c4233127, type: 3} m_Script: {fileID: 11500000, guid: 00a9f9c2ce4a41fdaadcfb24c4233127, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_RigBuilder: {fileID: 5341614616933970905}
m_ReAnimator: {fileID: 3871962590503854066} m_ReAnimator: {fileID: 3871962590503854066}
m_HandsLayerIndex: 2 m_HandsLayerIndex: 2
onQuickAttackFinished: onQuickAttackFinished:
@@ -817,6 +818,7 @@ MonoBehaviour:
mask: {fileID: 0} mask: {fileID: 0}
isAdditive: 0 isAdditive: 0
targetWeight: 0 targetWeight: 0
tickMode: 0
references: references:
version: 2 version: 2
RefIds: RefIds: