Hiya, so the title is probably slightly confusing, so to explain it in detail: once I have passed a touched part (part) and the part that touched it (otherPart) to a function, how would I go about checking whether or not the otherPart is travelling in the same direction as the way the part is facing? In other words, how would I get a direction from the way the part is facing (its orientation) and the way the otherPart is moving (its velocity) such that they can be compared?
You can use the LookVector
, RightVector
, and UpVector
properties of the part’s CFrame to get the normal directions of any of it’s faces.
You could then compare one of those with the other part’s velocity vector.
The angle between two vectors is equal to:
math.acos(a:Dot(b) / (a.Magnitude * b.Magnitude))