• Need help with vector math and util.tracehull
    0 replies, posted
I am pretty horrible at trying to do vector math to try and find points in space, so I'm hoping someone can help me I've been trying to write a proper melee swep for a little bit now and haven't had too much luck. I want to do a trace hull with max and mins to actually simulate a knife swipe instead of just doing a single line trace. The problem is, I cant figure out how to find the max and mins I should be using. I do not have the code in front of me, so this will be more or less pseudo code of what I currently have. [lua] local pos = ply:GetShootPos() local dir = ply:GetAimVector() trace = until.TraceHull( start = pos, end = pos + (40 * dir), min = pos + (dir * vector(0, -15, -15)), max = pos + (dir * vector(10, 10, 15), filter = self) [/lua] This doesn't work and I'm pretty sure it is because I'm calculating my max and min incorrectly. I essentially just want a box in front of the player. I also don't fully understand how tracehull works. Since it is 'looking' in a larger area instead of just one line, how would things such as trace.hit even work since one part of the trace may hit something but the other may not? Same with trace.Entity, since I can hit multiple ents now, what would be returned? What if an entity is behind a prop? Would I hit both the prop and the entity or does the tracehull hit the prop first and ignore the entity like a trace? To me, I'm envisioning tracehull being similar to findInBox which would return everything within that box. I just can't see how tracehull could do a bunch of traces from my start, to every point in the "box" and know if it can reach it or not.
Sorry, you need to Log In to post a reply to this thread.