• cam.Start3D2D help
    2 replies, posted
Is there any reason why this code is spawning my effect in a offset vector? I'll try subtracting some vectors later but hopefully someone can spot the reason for this madness? [lua] function ENT:Draw() -- self.BaseClass.Draw(self) -- We want to override rendering, so don't call baseclass. -- Use this when you need to add to the rendering. self:DrawModel() -- Draw the model. local ang = Angle( 0, 0, 0 ); local pos = self:GetPos(); local ExampleTexture = surface.GetTextureID( "sprites/sent_ball" ); local BoxSize = 128; cam.Start3D2D( pos, ang, 0.25 ); surface.SetDrawColor( 255, 255, 255, 255 ); surface.SetTexture( ExampleTexture ); surface.DrawTexturedRect( 0, 0, BoxSize, BoxSize ); cam.End3D2D(); end [/lua]
The 'offset' is probably the result of (0,0) being the top left corner of the box, to center it change line 14 to [lua] surface.DrawTexturedRect(-BoxSize/2,-BoxSize/2,BoxSize/2,BoxSize/2) [/lua]
[lua] local offset = Vector( 16, -16, 0 ); local pos = self:GetPos() + offset; [/lua] This seems to work fine. But if you have another suggestion, I'd be more than happy to look into it.
Sorry, you need to Log In to post a reply to this thread.