I am making an entity which is 3d2d, and i am trying to make a button, i saw that making a VGui button wont really work out, so i guess i’ll need to use some sort of a speical way to create a button.
Im guessing that you need to calc the players view and see if its looking at a Roundedbox, then to check if he presses E.
My question is how to calc the players view, to see that it is actully on the Rounded box, (if its the actuall way).
-- 3D2D vgui sample #3 -- By Overv if ( !vgui.Start3D2D ) then include( "3d2dvgui.lua" ) end button1 = vgui.Create( "DButton", frame ) button1:SetPos( 50, 50 ) button1:SetSize( 100, 20 ) button1:SetText( "Player One" ) button1.DoClick = function() surface.PlaySound("items/ammo_pickup.wav") end hook.Add( "PostDrawOpaqueRenderables", "DrawSample3D2DFrame", function() vgui.Start3D2D( pos, ang, 0.5 ) button1:Paint3D2D() vgui.End3D2D() end )
for example. it’s not complete but that’s how it’s done
If you’re looking for the code thanks to Overv there is a free copy https://github.com/GModCoders/3d2d-vgui
no credits to me
edit: that calculating thing is in the 3d2dvgui.lua file that you have to download from the github link
at the minute i got issues with it, i posted a bug report hopfully Matt will answer it soon, until then, is there any other way?
the code is outdated, and i am pretty sure you can’t interact with derma elements in cam3d2d
so back to my first post regarding it…
Do i need to make a simplebox with draw, and then see if the player is looking at it and pressing e?
If i do, mind telling me how i see if a player is looking at a certain object?
how do you plan on detecting if you’re looking at a derma object in space?
i dont know, but i saw a script on coderhire which uses it, its dan’s printer script:
You need to use util.IntersectRayWithPlane to work out where on your ‘screen’ you are aiming, then use maths to check whether that position is inside the rectangle of your button.
first of all thanks
Second of all, im not quite sure what are the arguments there.
Mind giving me a small example?
do you want to be completely fed code? just look at the arguments on the wiki page
As i said i didn’t quite understanded the arguments…
And all i wanted is an example, not to be “fed code”…
An “example” that you can then use for yourself without any work in your part.
an example to show what the hell are thoes paramters, cuz i have no idea whats “rayOrigin” or “planePosition”…
It tells you what they mean on the wiki page…
not sure whats:
any position of the “plane”, nor a “ray”.
the former being any coordinates on the plane, and the latter being a line between two points in 3D space, or to be technical, it’s a point and a directional vector which extends infintely
A ‘ray’ is a line extending through 3d space (eg, the line from your gun to your aim position).
The ‘plane’ is your screen you are drawing the button on.
For the parameters:
You can use any point along the ray but normally you use the start of it (eg, ply:ShootPos())
The direction is the direction it is heading (eg, ply:GetAimVector())
The plane position is where your ‘screen’ is for your button.
The plane normal is the direction the screen is facing (eg, something like screenAngle:Forward())
so how would i define the whole position of the button?
i mean how do i define the size of the button in it?
never mind, i got some small help from a friend, and figured it out
But for some reason i am trying to see if the guy is looking between it, but for some reason it doesn’t recognise the value im using with the util.IntersectRayWithPlane.
This is my code:
local entityvector= Vector(self.Entity:GetPos()) local vectoronboard = util.IntersectRayWithPlane(ply:GetShootPos(), ply:GetAimVector(),entityvector,self.Entity:GetAngles():Forward()) if (vectoronboard.x < self.Entity:GetPos().x + 85 and vectoronboard > self.Entity:GetPos().x + 15 and vectoronboard.y < self.Entity:GetPos().y + 55 and vectoronboard.y > self.Entity:GetPos().y + 25)
and my error says:
When i try and print sometimes i get nil, and sometimes i get a vector.