So I was trying to make "smarter" bombs by trying to make them move towards a player to help the bomb hit them. I don't got much of an idea of how to do it, or if it's possible. If anybody knows how to do this, please help. Thanks!
Thanks to Fifkee, this question was solved! Thank you!
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 --if the other part is closer to the right side return 'Right', p2/(modulofactor or 1) else --if the other part is closer to the left side 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