Skip to content

Conversation

@dhkatz
Copy link
Contributor

@dhkatz dhkatz commented Oct 29, 2023

This is a PR which fixes #35

As far as I can tell this hasn't broken anything else but if someone can confirm that would be great.

I ended up adding a new function specifically for weapons because we only want to do FOV corrects for view models.

I did not automatically convert the position and angles using ENTITY:LocalToWorld(pos) because I assumed most people will be positioning view model UI relative to bone positions and ENTITY:GetBonePosition(n) always returns values in world space coordinates.

Before Fix:

gmod_huaxYFYBfd.mp4

Notice how the mouse does not line up with the cursor while the screen clicker is active (the virtual cursor is being rendered by the weapon's SWEP:PostDrawViewMode)

After Fix:

gmod_hKxs9xbz2R.mp4

I can interact with both the button positioned in the world and the button positioned on the view model accurately to the mouse cursor.

@dhkatz
Copy link
Contributor Author

dhkatz commented Oct 29, 2023

Ok it looks like this did break some things, so I might need to add a specific function for weapons like entities have

@dhkatz
Copy link
Contributor Author

dhkatz commented Oct 29, 2023

Ok I seem to have fixed the issues by adding a new function to only correct FOV using view model when rendering for a weapon

Copy link
Contributor

@wyozi wyozi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks. If you can just add ScrW and ScrH to .luacheckrc, I can merge this. Could also add a short mention to README

@wyozi
Copy link
Contributor

wyozi commented Jun 2, 2025

Good stuff

@wyozi wyozi merged commit 13d80f5 into wyozi-gmod:master Jun 2, 2025
1 check passed
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.

ImGUI on viewmodel doesn't properly find cursor position

2 participants