#How to calculate hits outside of workspace?
1 messages · Page 1 of 1 (latest)
How are you detecting hits?
just record sum movements
like hitbox datas ig
wow a staff replying to scripting help
crazy
most helpful s2
:>
I am not detecting hits yet, thats what i want to do, the Lag Comp module returns players at a timestamp and their positions
I just want to compare it to the hitbox to find if it is inside the hitbox
im thinking about using pointtobjectinspace
whatever its called
Alright I don't have very much experience with melee combat and such
But the goal seems simple enough
You're just trying to see if a point is within any hitboxes right
Alright this probably isn't the most efficient or cleanest solution but you could just loop through all players in the game and then use a simple mathematical approach to check if the point is in their hitbox
I am doing a modified version of that
but i've optimized it up abit by only calculating for players like 20 studs in magnitude away from the player
Alright
So yeah
easiest approach would be like you mentioned
Use PointToObjectSpace to convert the point into the hitbox's object space
Then check if the point's X Y and Z are smaller than or equal to half the size of the box
Here
ill include a slight buffer tho
then just increase the size of the hitbox
local pointPosition = ...
local hitboxCFrame = ...
local hitboxSize = ...
local pointPosObjectSpace = hitboxCFrame:PointToObjectSpace(pointPosition)
local isInHitbox = math.abs(pointPosObjectSpace.X) <= hitboxSize.X/2 ..etc for all axes
there
thats all you should need
np