Location of weapon worldmodel clientside & weird renderbounds
0 replies, posted
I'm trying to set the renderbounds of a SWEP I'm making that fires a beam at another entity.
However, when I call GetPos on the SWEP, it returns the player's crotch.
I solved that by using the hand bone like this:
local bone = self:LookupBone("ValveBiped.Bip01_R_Hand")
local matt = self:GetBoneMatrix(bone);
local pos = matt:GetTranslation();
pos = pos
+ matt:GetForward() * 5
+ matt:GetRight() * 5;
self:DrawMagicBeam(pos);
But that doesn't help me when setting the render bounds. I tried debugging the issue in thirdperson with this code
function SWEP:Think()
local min, max = self:GetRenderBounds();
local pos = self:GetPos();
local centre = self:OBBCenter();
local t = FrameTime();
debugoverlay.Cross(pos, 5, t, color_white, true);
debugoverlay.Cross(self:LocalToWorld(centre), 5, t, color_red, true);
debugoverlay.Cross(self:LocalToWorld(min), 4, t, color_green, true);
debugoverlay.Cross(self:LocalToWorld(max), 4, t, color_blue, true);
end
Which shows two(!) max bounds:
https://i.imgur.com/6cn1uDT.png
I also tried displaying them with
debugoverlay.Box(pos, min, max, t, color_white, true)
which results in two hard to see boxes:
https://i.imgur.com/dbFefKR.png
What am I doing wrong here?
Full SWEP code on github
Sorry, you need to Log In to post a reply to this thread.