View Single Post
backwards
AlliedModders Donor
Join Date: Feb 2014
Location: USA
Old 05-06-2020 , 21:34   Re: Trace from a position towards a hull.
Reply With Quote #2

The best way to do this while using the engines trace ray function would be to create a model with a hitbox (same size as the player hull bounds) and spawn it at the players position. You then just race against this objects hitbox. If you want to do this without the model prop then you will have to manually raytrace yourself with just math and a visibility function to the box using a normal raytrace to the bounds of the virtual hitbox you've defined + rotation. I would suggest using a FOV check against the player to see if you are aiming near the player for optimizations first. Then check visibility with a raytrace to this player (minus the distance of the origin to its longest edge length (using players hulls will be 32 units)). If this raytrace hits nothing, then you know the path is clear to this object and a good to then manually trace against. All you have to do then is align the rotations to 90 degree axis and enumerate a length of a vector which you extend + 1 unit in a for loop for a max distance. Then check if this point is within the min\max bounds of the hitbox you've defined
__________________
I highly recommend joining the SourceMod Discord Server for real time support.
backwards is offline