• Cam3d2d multiple entities
    5 replies, posted
Hey, I'm trying to make it so that my cam3d2d hud will show on my entity even if I spawn in multiple times, I currently have it drawing in a PostDrawTranslucentRenderables hook so that it will show in front of an entity that it creates, but it seems that when I spawn in multiple of my entity the hook gets overridden. If anybody knows how to fix this, your help would be very much appreciated. Thank you!
Post your code
hook.Add("PostDrawTranslucentRenderables", "GeneratingBombCAM3D2D", function() if bomb_gen == nil or bomb_gen == NULL then return end local ang = bomb_gen:GetAngles() local pos = bomb_gen:GetPos() + ( bomb_gen:GetAngles():Forward() * 10.7) + ( bomb_gen:GetAngles():Up() * 23 ) ang:RotateAroundAxis(ang:Right(),-90) ang:RotateAroundAxis(ang:Up(),90) cam.Start3D2D(pos,ang,0.05) if bomb_gen:GetBombCountdown() != nil && bomb_gen:GetGeneratingBomb() == 1 then  --draw.RoundedBox(15,-20,715,217.5,75,Color(0,0,0)) draw.SimpleText(string.FormattedTime( math.Round(bomb_gen:GetBombCountdown()), "%02i:%02i" ) ,"bomb_generating",90,725,Color(180,0,0),TEXT_ALIGN_CENTER) end if bomb_gen:GetBombReady() == 0 && bomb_gen:GetGeneratingBomb() == 1 then draw.SimpleText("Generating","bomb_generating",90,635,Color(180,0,0),TEXT_ALIGN_CENTER) end if bomb_gen:GetBombReady() == 1 then draw.SimpleText("Bomb Ready!","bomb_generating",90,635,Color(180,0,0),TEXT_ALIGN_CENTER) end cam.End3D2D() end)
Its because you are using the same variable (bomb_gen) for every entity, you want to make it unique for each instance of your entity. Try this (just assign your entity to the bomb_gen variable in there) bomb_gen
Well, I do already have bomb_gen = self, in my ENT:Draw function. Would this do the same thing or nah? function ENT:Draw() self:DrawModel() bomb_gen = self local ang = self:GetAngles() local pos = self:GetPos() + ( self:GetAngles():Forward() * 13) + ( self:GetAngles():Up() * 23 ) ang:RotateAroundAxis(ang:Right(),-90) ang:RotateAroundAxis(ang:Up(),90) cam.Start3D2D(pos,ang,0.05) --draw.RoundedBox(0,-120,-100,200,200,Color(150,150,150)) draw.SimpleText(LocalPlayer():Nick().."'s","bomb_gen",90,-80,Color(200,200,200),TEXT_ALIGN_CENTER) draw.SimpleText("Bomb Generator","bomb_gen",90,-30,Color(200,200,200),TEXT_ALIGN_CENTER) cam.End3D2D() end
No, because every time you spawn another entity, it gets assigned to the bomb_gen variable, thus overwriting the previous one.
Sorry, you need to Log In to post a reply to this thread.