Ok this is kind of hard to explain, but I want to make a wind system that revolves around a line at any distance from that line, like wind travelling in parallel paths around a globe. By this I mean I provide a function a 3D point and it gives me the direction of the wind at that point.
To illustrate this, here is what I mean in circular form.
The wind is revolving clockwise around the origin of the circle, even when you go closer.
In a similar vein, I want to make what is basically an infinite amount of those circles sandwiched together:
Orange is the line that they’re revolving around. Green is the wind direction at that point, which is what I’m trying to get.
Note that the wind paths are all parallel to each other, they dont meet at a specific spot.
I don’t know how to even start this, because I’ve been having trouble with just the 2d version.
Also keep in mind that the sphere is just to show that getting closer to the line doesn’t change the wind path, in reality I guess it’s a cylinder of any size that the wind is revolving around.
I’d also like a way to reverse this wind to go the opposite direction.
These concepts are somewhat foreign to me, and I just want an explanation of how each of these problems could be solved. I am not asking for you to script the system for me.
UPDATE:
I figured it out a while ago but forgot to update this post.
This is a module script I made that does exactly what I wanted
local Wind = {}
local lineOrigin = game.ServerStorage.WindConfigs.WindLineOrigin.Value.Unit
local lineDirection = game.ServerStorage.WindConfigs.WindLineDirection.Value.Unit
function closestPointFromPosition(pos)
local dir = (pos-lineOrigin)
local dist = dir.Magnitude
local ray
if dir.Unit:Dot(lineDirection) >= 0 then
ray = Ray.new(lineOrigin,lineDirection)
else
ray = Ray.new(lineOrigin,-lineDirection)
end
return ray:ClosestPoint(pos)
end
function windDirectionFromPoints(point1, linePos, clockwise)
local directionToCircle = (point1 - linePos).Unit
local tangentDirection = directionToCircle:Cross(lineDirection)
if not clockwise then
tangentDirection = -tangentDirection
end
return tangentDirection
end
local clockwise = true
function Wind.getWindAtPos(pos)
lineOrigin = game.ServerStorage.WindConfigs.WindLineOrigin.Value.Unit
lineDirection = game.ServerStorage.WindConfigs.WindLineDirection.Value.Unit
local linePos = closestPointFromPosition(pos)
local tangentVector = windDirectionFromPoints(pos, linePos, clockwise)
return tangentVector
end
return Wind
Anyone is free to use it if they want!
Here’s it in action with my wind particles swirling in a circle around an “island”