Fix cursor position when weapon FOV does not match player FOV #42
+23
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 andENTITY: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.