• Determining which side the player is looking at on an object
    2 replies, posted
Hi there, So I have this problem where I have a cuboid model and I want to know which side the player is looking at. I made a little diagram to show what I want: [IMG]https://s32.postimg.org/pr2hns4qd/eyesight.png[/IMG] So I want to know if they are looking at the green side of the shape and not if they are looking at the red parts. How would I go about doing this? Thanks
There are a few ways to do this, based on different kinds of results from [url=http://wiki.garrysmod.com/page/Structures/TraceResult]the trace results[/url] of the player's eye trace. For example, you could take the HitNormal, use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Vector/Angle]Vector:Angle[/url] and then [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/WorldToLocalAngles]Entity:WorldToLocalAngles[/url] using your cuboid entity. That will give you an angle that points from the center of the entity to the face being looked at - and some simple maths will figure out which surface it actually is in your format of choice. Another option is to just use HitTexture if your cuboid has a different texture on each face, or the face you want to check.
Works perfectly thanks for your help :D
Sorry, you need to Log In to post a reply to this thread.