• Just need some help with positioning 3D2D cam GUI
    4 replies, posted
Hey, basically I want to re position my GUI on my prop so instead of it being in the centre on the prop I want it on the surface. This is what I'm getting currently : Screenshot I want to move the GUI up so it's on the surface of the prop, this is the code I've currently got : include("shared.lua") surface.CreateFont( "vendingtitle", {     font = "Arial",      extended = false,     size = 300,     weight = 500,     blursize = 0,     scanlines = 0,     antialias = true,     underline = false,     italic = false,     strikeout = false,     symbol = false,     rotary = false,     shadow = false,     additive = false,     outline = false, } ) function ENT:Draw()     self:DrawModel()     local ang = self:GetAngles()         ang:RotateAroundAxis(self:GetAngles():Right(), 90)                   cam.Start3D2D(self:GetPos() , ang , 0.09)         draw.RoundedBox(0,200,200,600,2000,Color(64,64,64,255))         draw.RoundedBox(0,200,200,1000-400,1000-400,Color(32,32,32,120))         draw.SimpleText("Vending Machine", "vendingtitle",500,500,Color(120,33,13,255))     cam.End3D2D() end
local ang = self:GetAngles() ang:RotateAroundAxis(self:GetAngles():Right(), 90) This is where your Problem lies. You hagve to change the angle the Image is drawn in. I had the same Problem. You havet to Experiment with it. Use the following the arguments to position it right ang:RotateAroundAxis(self:GetAngles():Right(), -90) ang:RotateAroundAxis(self:GetAngles():Up(), 90) ang:RotateAroundAxis(self:GetAngles():Forward(), 90) Now the 90's that are written here next to the Arguments Right Up and Forward decide to which degree the Angle of the Drawn picture is changed in that Plane. Add the three arguments i gave you and experiment with the numbers
I'm putting it on a 3D prop and the corner of the GUI always seems to be glued to centre of the prop, is it the 'RotateAroundAxis' what's the problem? I'm trying different things and all getting the same kinda stuff just different angles. I tried your solution before and I was messing with it for 2 hours straight but it isn't getting any closer to what I want.
If you want to change where your 3D2D is positioned, adjust it using Self:GetPos() and adding/subtracting vectors from it. local pos = self:GetPos() local ang = self:GetAngles() pos = pos + (ang:Right() * 5) --This would move it to the right, relative to the prop. If you wanted to adjust the position in multiple ways do this: pos = pos + (ang:Right() * 5) + (ang:Up() * 5) + (ang:Forward() * 5) cam.Start3D2D(pos, ang, 1) --do your 3D2D magic here cam.End3D2D() Spytroner already told you how to change the orientation. Just adjust the number being multiplied to move the 3D2D around.
while the above solutions will work, you might find it easier to use the LocalToWorld method. Local to world is pretty nice because all you need to do is give it the world position and angles, and the offset position and angles, and it will apply them for you. Example: local entPos, entAng = self:GetPos(), self:GetAngles() // get the entity's currrent position local offsetPos, offsetAng = Vector(0,0,100), Angle(0,90,) // set the offset position local finalPos, finalAng = LocalToWorld(offsetPos, offsetAng, entPos, entAng) cam.Start3D2D(finalPos, finalAng, 1) Another nice thing to note about LocalToWorld is it's always consistent; for the offfset Vector(x,y,z), x is always forward, y is always right, and z is always up.
Sorry, you need to Log In to post a reply to this thread.