Skip to content

Add lock_to_camera option for script hand motions - #766

Open
vacwave wants to merge 1 commit into
themrdemonized:all-in-one-vs2022-wpofrom
vacwave:lock_to_camera
Open

vacwave wants to merge 1 commit into
themrdemonized:all-in-one-vs2022-wpofrom
vacwave:lock_to_camera

Conversation

@vacwave

@vacwave vacwave commented Oct 16, 2026 •

Copy link
Copy Markdown

Script hand motions game.play_hud_motion are placed from the HUD camera, with movement layers and game.play_hud_anm layers applied on top. CamAttached script attachments are placed from the render camera without any of that. So when a hand motion ends where a CamAttached model takes over, like putting an item on the face, the two never line up exactly. Jump/land, sprint and walk bob, breathing and camera effectors that only move the render camera all shift the hands but not the attachment.

Adds an optional lock_to_camera key to the motions hud section, from 0 to 1, with an optional ramp time:

lock_to_camera = 1 -- 0-1
lock_to_camera_time = 0.5 -- optional, starts the motion at 0 and ramps up, seconds for a full 0-1 ramp

Scripts can also change it while the motion plays:

game.set_hud_motion_lock(target, seconds) -- target 0-1, ramps from the current value, 0 seconds sets it instantly

At 1, while the motion plays:

  • The animated arm(s) and the motion item are placed from the render camera instead of the HUD camera, the same camera CamAttached attachments use.
  • Movement and play_hud_anm layers are not applied to the animated arm(s). They keep ticking, so they are back in phase when the motion ends.

Between 0 and 1 the animated arm(s) blend from the normal HUD placement toward the locked one. So a motion can start with full bob and settle onto the camera before the hand-over, or start locked and let go partway through. If a motion starts locked (value above 0 and no ramp time), hands_position and hands_orientation apply fully from the first frame instead of blending in.

Default is 0, nothing changes unless the key is set. It is read per motion and reset in StopScriptAnim. One hand motions only lock that arm, a weapon in the other hand keeps its bob.

Even slight breathing and walking puts the positions out of sync. Instead of trying to copy positions over with larger engine changes, i decided to let specific motions blend toward the render camera after the layers are applied, so the layer code itself is untouched.

This works on its own, but for a CamAttached model to line up exactly its FOV also has to match hud_fov, which is what #758 adds. Also applies cleanly to all-in-one-vs2022-wpo-mt.

Example when installing filter and spawning a model after anim, top is hud_fov changes only, bottom this PR:

filter.mp4

@damoldavskiy

Copy link
Copy Markdown
Contributor

Would be cool to be able to set the blending factor, so with script control the anim can start with all the movement anims, and when "filter install" part of the anim start, disable it. Just an idea

@vacwave

vacwave commented Oct 17, 2026

Copy link
Copy Markdown
Author

Would make sense, i'll check if it doesn't add too much bloat. If it adds a lot i'll make it a seperate PR on top of this one.

@vacwave
vacwave marked this pull request as draft October 17, 2026 11:24
@vacwave

vacwave commented Oct 17, 2026

Copy link
Copy Markdown
Author

Tested ingame on MT build, seems to work fine. Looks better when the hand isn't completely static for the whole anim.

@vacwave
vacwave marked this pull request as ready for review October 17, 2026 15:16
@damoldavskiy

Copy link
Copy Markdown
Contributor

Would be great if you add new fields and the setter to lua_help_ex

@damoldavskiy

Copy link
Copy Markdown
Contributor

LGTM

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants