I’m currently programming some wind effects for a slide mechanic in my game; but I’ve encountered an issue which I can’t seem to wrap my head around.

The wind position is chosen based on this formula:

-- variables
local points = 10 -- this determines the quality of the circle; aka how many "points" it has.
local minimumRadius, maxiumumRadius = 10, 14 -- these values determine the radius of the circle given the min and max
-- actual values
local randomPoint = math.random(points)
local angle = (math.pi * 2 * randomPoint) / points
local radius = math.random(minimumRadius, maximumRadius)
local position = Vector3.new(math.sin(angle), math.cos(angle), 0) * radius

As you can see in the video below, the wind looks good and there’s no problem:

However I’m facing in the x direction in the video above. Take a look at what happens when I slide towards the z direction:

The wind is only spawning properly on the y axis and won’t create a circular shape like the first video. I believe the issues lies at this line here:

local position = Vector3.new(math.sin(angle), math.cos(angle), 0) * radius

Defining a new Vector3 variable; and the sin value is only changing on the x axis. I tried to visualize it using parts and it makes sense to why it doesn’t work:
( correct + looking in the x direction )

I want to solve this mathematically and not in a hacky way. I couldn’t find any sources about “creating a circle based on the character’s lookvector” kind of thing, so I’m here. Any help would be greatly appreciated.

When you add the Vector3 position, its axes are relative to the world space, which doesn’t change as your character’s orientation changes, so the circle will always be pointing in the same direction. However, if instead of using character.PrimaryPart.CFrame + position you use character.PrimaryPart.CFrame * CFrame.new(position), the position will be relative to the character’s orientation and should give you the result you need. See CFrame - Math Operations

20 being the amount of points. 13 and 16 being the random radius.
The next argument being where the place the actual wind part.
The one after that being the direction of the wind.
And the rest are sort of irrelevant ( just small tweaks like wind frequency etc… )

I’m honestly just stumped at this point haha. I’ll try mess around with it more and see if I can get something going.