So the Player will get hurt from the back, but not in the front.
local pos1 = dmginfo:GetDamagePosition()
local pos2 = victim:GetPos()
pos1.z = pos2.z
local aim = victim:GetAimVector()
aim.z = 0
local ang_Diff = math.acos((pos1-pos2):GetNormal():Dot(aim))*180/math.pi
if (ang_Diff < 90) then --you can change this number, less = bigger back, more = bigger front
–damage came from in front of the player
–damage came from behind the player
Are you using this to make a riot sheild?
Yes, I am modeller, and he’s helping me with code. How did you guess ?
Because what else would block from the front? I thought the same thing about a riot shield.
Do I put it in the Think or in the middle of the code?
Put it in your ScalePlayerDamage hook.
Maybe you’re better off creating an invisible prop in front off the player, it’s less elegant but it gets the job done.
[editline]15th January 2011[/editline]
How would I do that?
The problem with what you have is that you’ll still see blood from bullet impact, and you won’t be able to do any fancy ricochet effects off the shield.
…I am confused, just…post…some…thing…that would work.
Now now, that isn’t how you learn :eng101: Creating a prop in Lua is just creating a entity, there are tutorials on the Gmod Wiki for creating prop firing guns, it shouldn’t be too hard to work that into something you can stick in front of the player.
And if this is the model I think it is, it is a pretty nice model.