Cam2D3D on my new weapon viewmodel

Just as the title says i really have no idea on how to display a Cam2D3D text on part of a weapon viewmodel ( i made ).

You could probably use

SWEP:PostDrawViewModel or

SWEP:PreDrawViewModel, or

SWEP:DrawHUD

[editline]9th October 2016[/editline]

Or if it’s not a SWEP, then

Player:GetViewModel works in pretty much all drawing functions

Thanks for the hooks , but the specific part to my problem is me i just cant figure out how to position it correctly on the weapon

[editline]9th October 2016[/editline]

PreDrawViewModel should work great if i figure out how to draw cam2d3d properly

and yes its a swep :slight_smile:

Well a little more info on what/where and your viewmodel would help. Each viewmodel would require different positions. I’d suggest recompiling it with a bone or attachment in the position you want the 2D3D element drawn.

Then using viewmodel:GetBonePosition(viewmodel:LookupBone(“mybonename”)) to get it’s position in the 3d world.

You could also take the toolgun approach and add a 2d textured plane to the view model. Separate texture from the rest, then set it’s $basetexture via LUA with RenderTargets.

So you draw what ever you want to display to that render target, and set the materials texture to the render target. I suggest looking at the toolgun’s source code for more info on that though.

Thanks for the info i can tell this is going to be challenging thing and i thought the modelling part was hard.

[editline]9th October 2016[/editline]

im not the person to give up but i was trying to do the model the whole week finally got it to work so im going to just hire someone, but ill still try something with Cam2d3d because it looks cool thanks for the info and references!

For what it’s worth, the toolgun does it by rendering into a texture that’s part of the toolgun already. https://github.com/garrynewman/garrysmod/blob/master/garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/cl_viewscreen.lua

Thanks , sorry for the bump just thought id let you all know im going to use an attachment
then check if the local players viewmodel has the attachment ! then draw the text on the attachment!