Recently i have found myself in a need of tracing a cone from the players shoot pos.
I was originally using trace.Hull however i have come to realize that trace.Hull wont work since it is essentially traces a box.
So does anybody have ideas on a good way of doing this.
Does source have a built in function for this?
By tracing do you mean you want to essentially run ents.FindInCone on a specific player and see what it returns?
[lua]function _R.Player:IsEntInCone(ent, angle)
local dot = self:GetAimVector():Dot((ent:GetPos() - self:GetShootPos()):GetNormal())
return dot >= math.cos(math.rad(angle * 0.5))
end[/lua]
[QUOTE=Stonna;32982259]By tracing do you mean you want to essentially run ents.FindInCone on a specific player and see what it returns?
[lua]function _R.Player:IsEntInCone(ent, angle)
local dot = self:GetAimVector():Dot((ent:GetPos() - self:GetShootPos()):GetNormal())
return dot >= math.cos(math.rad(angle * 0.5))
end[/lua][/QUOTE]
I plan on using it for hit detection with a melee weapon.
That would work, if it i just wanted to find entities via position in a cone.
However your function would not work if the origin of an entity wasn't in the cone, but part of the entities hitbox was.
Sorry, you need to Log In to post a reply to this thread.