Hey, I'm currently trying to create a vending machine and I'm using 3D2D buttons on it. However I'm struggling to understand how to get the positions for the rectangle box which I want to make my button. I've seen examples of other people doing this and I don't fully understand how it works. Do I need to get the x,y,z positions of the top left of the box and bottom right with the hitpos on my cursor?
here is the code...
local ang = (self.Entity:GetPos() - player:GetShootPos())
local tr = util.GetPlayerTrace(player, ang)
local tr = util.TraceLine(tr)
local pos = self.Entity:WorldToLocal(tr.HitPos)
local entPos, entAng = self:GetPos(), self:GetAngles() // get the entity's currrent position
local offsetPos, offsetAng = Vector(48,0,24), Angle(0,180) // set the offset position
local finalPos, finalAng = LocalToWorld(offsetPos, offsetAng, entPos, entAng)
local eye = LocalPlayer():GetEyeTrace()
local cursorPos = eye.HitPos
local localcursorPos = self:WorldToLocal(cursorPos)
local ply = LocalPlayer()
local BoxColor = Color(55,55,55,255)
cam.Start3D2D(finalPos, finalAng, 0.1)
local eye = LocalPlayer():GetEyeTrace()
local cursorPos = eye.HitPos
local localcursorPos = self:WorldToLocal(cursorPos)
local ply = LocalPlayer()
-- This is the interactive 3D2D
draw.RoundedBox(0,579,-171,82,52, Color( 255,255,255,120 ))
draw.RoundedBox(0,580,-170,80,50, BoxColor)
if (localcursorPos.x*10 >= -9.9and localcursorPos.x <= -10and localcursorPos.y > -17and localcursorPos.y < 11.6) and (localcursorPos.z*10 > -9.9and localcursorPos.z*10 < -18.2) then
BoxColor = Color(32, 23, 75)
else
BoxColor = Color(55,55,55,255)
end
cam.End3D2D()
please edit your post and make the code in the codetag. So we can see syntax highlits and everything. its really weird to read it likr that
Under the text editor is a symbol
{}
Edited
Sorry, you need to Log In to post a reply to this thread.