xyzii Posted February 17, 2018 Share Posted February 17, 2018 Before you even mention it, I know of processLineOfSight and isLineOfSightClear. But those don't fix my issues as far as I'm aware. The two elements would be players and the obstacle is a custom element with no collision. On top of the element is a col shape though. I made a picture to show what I mean if you don't understand; I want to get something like this: if (element is in middle of those two players) then -- Do stuff end Link to comment
Moderators IIYAMA Posted February 17, 2018 Moderators Share Posted February 17, 2018 (edited) local getDistanceBetweenPointAndSegment3D = function (pointX, pointY, pointZ, x1, y1, z1, x2, y2, z2) local A = pointX - x1 local B = pointY - y1 local C = pointZ - z1 -- local D = x2 - x1 local E = y2 - y1 local F = z2 - z1 -- local point = A * D + B * E + C * F local lenSquare = D * D + E * E + F * F local parameter = point / lenSquare local shortestX local shortestY local shortestZ if parameter < 0 then shortestX = x1 shortestY = y1 shortestZ = z1 elseif parameter > 1 then shortestX = x2 shortestY = y2 shortestZ = z2 else shortestX = x1 + parameter * D shortestY = y1 + parameter * E shortestZ = z1 + parameter * F end local distance = getDistanceBetweenPoints3D(pointX, pointY,pointZ, shortestX, shortestY,shortestZ) -- return distance end 3D version of this one: https://wiki.multitheftauto.com/wiki/GetDistanceBetweenPointAndSegment2D Useful for detecting if something is between 2 points. Edited February 17, 2018 by IIYAMA 2 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now