Can't get SetEyeAngles to work so it limits a player's view
9 replies, posted
So, I opened an old addon that I was doing like 2 years ago and I tried to make it work and I've been trying to get this working but I don't know how to limit a player's view, make them only see from 0° to 90° to the right when "ply.something = true" and 90° to 0° to the left when "ply.something2 = true".
I just cant get this working and this is really stressing me out.
Could any of you guys give me hand?
Thanks
Some code might help
Edit: Im wrong!
[QUOTE=Palooz;50229756]EyeAngles are just the angle the eyes are pointing, used to determine the direction from the player pos or EyePos.
The only way your going to block half of the view is to draw a rectangle over whichever half you'd like.[/QUOTE]
He's not trying to block half the view, he's trying to clamp the view between two angles
[editline]30th April 2016[/editline]
Try using a hook like [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/Tick]GM:Tick[/url] (but maybe one that runs a little faster), then use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/EyeAngles]Entity:EyeAngles[/url] to get the current eye angles of the player, then use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/SetEyeAngles]Player:SetEyeAngles[/url] to set the angles as the previous angles that were gotten, but make sure to use something like [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/math/Clamp]math.Clamp[/url] to clamp the yaw of the angle
E.G.
[CODE]
hook.Add( 'Tick', 'ClampView', function()
local ang = LocalPlayer():EyeAngles()
LocalPlayer():SetEyeAngles( Angle( ang.p, math.Clamp( ang.y, 0, 90 ), ang.r ) )
end )
[/CODE]
The only problem with that code is that I don't know how to properly clamp the yaw so it gets clamped to the left or the right, but some math god will probably stumble across this thread and tell you at some point
Ahhh I see what you mean, interpreted the op wrong my bad. :smile:
[QUOTE=MPan1;50230089]
[CODE]
hook.Add( 'Tick', 'ClampView', function()
local ang = LocalPlayer():EyeAngles()
LocalPlayer():SetEyeAngles( Angle( ang.p, math.Clamp( ang.y, 0, 90 ), ang.r ) )
end )
[/CODE]
[/QUOTE]
This would theoretically work if he really wanted the 0 and 90 angles, but how can you know those are the exact angles that will fit your needs?
[QUOTE=JasonMan34;50230774]This would theoretically work if he really wanted the 0 and 90 angles, but how can you know those are the exact angles that will fit your needs?[/QUOTE]
He can adjust them?? That should give him the concept he needs to finish the rest himself
[QUOTE=Melted Bu11et;50231373]He can adjust them?? That should give him the concept he needs to finish the rest himself[/QUOTE]
I think you misunderstood - Those angles might work at one part/area of the map, but not the other
I definitely use [url=http://wiki.garrysmod.com/page/GM/InputMouseApply]InputMouseApply[/url] to modify viewangles on the client.
[QUOTE=JasonMan34;50231597]I think you misunderstood - Those angles might work at one part/area of the map, but not the other[/QUOTE]
Good point, but it sounds like hes capable of doing the rest himself. I'm not trying to be a dick, but I don't think that straight up spoon feeding will help him in the long run either
Sorry, you need to Log In to post a reply to this thread.