Hello.
I'm wondering, is there like an eyetrace or something that can detect if a player's looking at 3D2D?
Thanks.
If you're only using a 3d2d floating in the air by itself, then it would be very difficult to do without some high level 3-d vector mathematics. It'd be a pain in the ass.
However, a simpler way, albeit more cpu intensive, is to create an invisible entity on top of your 3d2d panel, and detect if their eyetrace collides with that entity instead.
If you've already "attached" your 3f2d panel to an entity, such as a computer screen, then you can use the screen as a backdrop for the 3d2d and determine which part of the screen the player is looking at with that method.
[QUOTE=CallMePyro;45269378]If you're only using a 3d2d floating in the air by itself, then it would be very difficult to do without some high level 3-d vector mathematics. It'd be a pain in the ass.
However, a simpler way, albeit more cpu intensive, is to create an invisible entity on top of your 3d2d panel, and detect if their eyetrace collides with that entity instead.
If you've already "attached" your 3f2d panel to an entity, such as a computer screen, then you can use the screen as a backdrop for the 3d2d and determine which part of the screen the player is looking at with that method.[/QUOTE]
If i had an invisible entity however, wouldn't i have to have a model the exact size as the 3d2d?
[T]http://23.88.229.109/printer.png[/T]
That's what I'm working with, I don't do DarkRP, but i'm just trying to get something together to sell on CoderHire.
[editline]2nd July 2014[/editline]
Now that i think about it, can't i just use the player eye trace with [URL="http://wiki.garrysmod.com/page/Global/WorldToLocal"]WorldToLocal[/URL], and [URL="http://wiki.garrysmod.com/page/Vector/WithinAABox"]WithinAABox[/URL]?
The easiest way would be to not draw it from a certain distance.
[lua]
if self:GetPos():Distance(LocalPlayer():GetPos()) > 400 then return end
[/lua]
After a little of messing around, I came up with this:
[code]
local plytrace = LocalPlayer():GetEyeTraceNoCursor();
if ( plytrace.Entity == self ) then
for k,v in pairs( pbuttons ) do
if (self:WorldToLocal(plytrace.HitPos):WithinAABox(Vector(-6 + (2.5*k - 2.5), -9, -90), Vector(-4.3 + (2.396*k - 2.396), -2.5, 90) ) ) then
pbuttons[k][3] = true;
else
pbuttons[k][3] = false;
end
end
end
[/code]
It works, probably not very good code though.
[url]http://samuelmaddock.github.io/glua-docs/#?q=intersectraywithplane[/url]
Is what you are looking for.
Sorry, you need to Log In to post a reply to this thread.