✓ Accepted answer
utilize cframe rightvector and leftvector (leftvector is -rightvector), add the left/rightvector to position and get the between the bomb position and the newly-generated position value via magnitude and shift add the magnitude to the left/right depending if the bomb position is closer to the left/right.
an example of this is for my (broken) camera system:
function isCloserToPosition(p, op, modulofactor)
p = p.CFrame;
local p1 = math.abs(((-p.RightVector + p.Position) - op.Position).Magnitude);
local p2 = math.abs(((p.RightVector + p.Position) - op.Position).Magnitude);
if (math.floor(p1) > math.floor(p2)) then
return 'Right', p2/(modulofactor or 1)
else
return 'Left', p1/(modulofactor or 1);
end
end
i add the right and negativerightvector to the position, and then I subtract it from the defender's position. then i check if the first magnitude is greater than the 2nd, if so that means that the 2nd magnitude is closer to the target part (op). then i return 'left' or 'right' depending on the distance magnitude. since the magnitude is the difference between two Vector values, you can easily add/subtract magnitude depending on their relationship to the left/right of the bomb by storing the side that's closest (that's why I use return 'Right', ... and return 'Left', ...)
i think this makes sense, if you have any questions dont be afraid to ask
7 comments
Very interesting. I will test this.
modulofactor is there because again, it's simply an example, pure coincidence that I had something that matched your question.
Wait, how exactly would I use this? Bomb, player, what?
..you weren't supposed to use my code. read the huge paragraph i sent lol
No, I get what "p" and "op" is, but "modulofactor" is a new thing used in a new place for me.
Or would it be fine to just set modulofactor to 0?
Nevermind, it works just fine.