- Status
- Offline
- Joined
- Mar 3, 2026
- Messages
- 690
- Reaction score
- 457
Anyone currently digging into the Source engine and fighting with viewmodel snaps? I am running into a persistent issue when toggling thirdperson in CS: Source where the viewmodel animations break for several frames upon switching back to first-person. Additionally, the leg animations are occasionally tripping out—either T-posing or playing the wrong sequence—the moment the camera shifts.
The logic is handled within a override_view detour. While the camera collision and interpolation feel smooth, the state transition for the internal engine flag seems to be causing the animation state machine to lag behind.
The Technical Mess:
Current Implementation:
Has anyone dealt with this specific animation sequence bug in CSS before? I am thinking about manually forcing the sequence update or checking if there is a better hook to manage the camera state without upsetting the viewmodel.
Drop your suggestions for fixing the T-pose below.
The logic is handled within a override_view detour. While the camera collision and interpolation feel smooth, the state transition for the internal engine flag seems to be causing the animation state machine to lag behind.
The Technical Mess:
- Toggling thirdperson OFF results in the viewmodel snapping or disappearing for a few frames before resetting.
- Leg animations fail to transition correctly, resulting in an occasional T-pose on the first frame of activation.
Current Implementation:
Code:
void override_view_detour(void* rcx, CViewSetup* pSetup) {
original(rcx, pSetup);
if (!pSetup || !local || !local->is_alive()) {
if (g_was_tp) {
i::input->m_fCameraInThirdPerson() = false;
g_was_tp = false;
}
return;
}
bool want_tp = is_thirdperson_active();
if (want_tp && !g_was_tp) {
i::input->m_fCameraInThirdPerson() = true;
tp_first_frame = true;
g_was_tp = true;
} else if (!want_tp && g_was_tp) {
i::input->m_fCameraInThirdPerson() = false;
g_was_tp = false;
}
if (g_was_tp) {
vec3 fwd, right, up;
math::angle_vectors(pSetup->Angles, &fwd, &right, &up);
float dist = fCFG[fCfg::misc_thirdperson_dist];
if (dist < 30.f) dist = 120.f;
vec3 eye = local->get_eye_pos();
vec3 end = eye + fwd * -dist;
Ray_t ray;
ray.Init(eye, end, {-9,-9,-9}, {9,9,9});
CTraceFilterWorldAndPropsOnly filter;
trace_t tr;
i::engine_trace->trace_ray(ray, MASK_SOLID, &filter, &tr);
static float last_rt = 0.f;
if (tp_first_frame) {
tp_origin = tr.endpos;
last_rt = i::global_vars->realtime;
tp_first_frame = false;
}
float dt = i::global_vars->realtime - last_rt;
last_rt = i::global_vars->realtime;
if (dt <= 0.f || dt > 1.f) dt = 0.016f;
static vec3 last_ang = {};
float ang_delta = std::abs(pSetup->Angles.x - last_ang.x)
+ std::abs(pSetup->Angles.y - last_ang.y);
last_ang = pSetup->Angles;
float t = 1.f - std::exp(-(ang_delta > 0.1f ? 100.f : 80.f) * dt);
tp_origin.x += (tr.endpos.x - tp_origin.x) * t;
tp_origin.y += (tr.endpos.y - tp_origin.y) * t;
tp_origin.z += (tr.endpos.z - tp_origin.z) * t;
pSetup->Origin = tp_origin;
}
}
I suspect the leg animation issue might be related to how the sequence is initialized when m_fCameraInThirdPerson is flipped on. For the viewmodel snap, it might be necessary to force a redraw or wait for a specific frame count before re-enabling the first-person model to avoid that jittery transition.
Has anyone dealt with this specific animation sequence bug in CSS before? I am thinking about manually forcing the sequence update or checking if there is a better hook to manage the camera state without upsetting the viewmodel.
Drop your suggestions for fixing the T-pose below.