Gamemode.CalcView
From GMod Wiki
Event Hook | |
Hook Name | CalcView |
Syntax | GM:CalcView( Player player, Vector origin, Angle angles, Float fov ) |
Description | Allows override of the default view. |
Returns | Table |
Lua State | |
BBCode | [b][url=wiki.garrysmod.com/?title=Gamemode.CalcView]Gamemode.CalcView [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Examples
Additional Notes
- Do NOT return anything unless you need to change the player's view that frame.
- This function does not overwrite the player's eye angles, it merely simulates them.
- Only changes where the players view is drawn from, doesn't change their actual position, so traces and bullets are unaffected.
- If you want to move the view model you can include vm_origin and vm_angles in the return table.
- You may also include fov in the table that gets returned if you want to modify the user's field of view angle.
- Returning just a table here breaks the base CalcView hook and SWEP:GetViewModelPosition, to fix that do this:
function MyCalcView(ply,origin,angles,fov) //Do your stuff -- Example: local view = GAMEMODE:CalcView(ply,origin,angles,fov) //return the modified values //if in a gamemode do //return self.BaseClass:CalcView(ply,origin,angles,fov) end
- NOTE: The above function works perfectly but if your using vm_origin or vm_angles, You have to return a diffrent function that doesnt use vm_* when your using C++ weapons.
- NOTE2: The below function is false and written in old terms by garry, The above code is more appropriate.
function MyCalcView(ply,origin,angles,fov) //Do your stuff //return the modified values return GAMEMODE:CalcView(ply,origin,angles,fov) //if in a gamemode do //return self.BaseClass:CalcView(ply,origin,angles,fov) end