ludic.character: the look goes up and down to 89 degrees (was -55..35), and the orbit's heading holds when the camera is straight over or under the pivot; ludic.aim: aim_ahead, whether a point is before the view

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-29 12:14:04 +03:00
parent 765d800842
commit 0b35f810b6
3 changed files with 21 additions and 2 deletions

View file

@ -44,7 +44,8 @@ export function char_camera_third(character_st: mut CharacterState, dt: float) -
character_st.chr_eye_z = cz
let ddx = ax - cx
let ddz = az - cz
character_st.chr_eye_yaw = Math.atan2(-ddx, -ddz)
# straight over or under the pivot the offset has no heading of its own: keep the look's
if ddx * ddx + ddz * ddz > 0.0025 { character_st.chr_eye_yaw = Math.atan2(-ddx, -ddz) } else { character_st.chr_eye_yaw = character_st.chr_cam_yaw }
character_st.chr_eye_pitch = Math.atan2(character_st.chr_piv_y - cyy, Math.sqrt(ddx * ddx + ddz * ddz))
}

View file

@ -55,7 +55,9 @@ function chr_gait(character_st: mut CharacterState, dist: float, dyaw: float, dp
}
}
# as far up and down as a view goes, a degree short of straight (where the heading would flip)
const CHR_PITCH_MAX: float = 1.553
function chr_look(character_st: mut CharacterState, dyaw: float, dpitch: float) -> void {
character_st.chr_cam_yaw = character_st.chr_cam_yaw + dyaw
character_st.chr_cam_pitch = Math.clamp(character_st.chr_cam_pitch + dpitch, -0.96, 0.61)
character_st.chr_cam_pitch = Math.clamp(character_st.chr_cam_pitch + dpitch, -CHR_PITCH_MAX, CHR_PITCH_MAX)
}