So yesterday when the Wind Beta was announced, I put GlobalWind support into my game.
One of the things i did is make the wind change randomly.
I wanted to add more, but I’m running into a problem.
I want to make this flag pivot in the direction of the wind, but I’m not very experienced with pivoting models.
I already set a PrimaryPart and have the model set up to pivot.
How would I go about doing this?
Having a PrimaryPart set overrides the WorldPivot.
You would use CFrame.lookAt to get the orientation from the direction and add the current position to it.
local Flag = workspace.Flag
local function UpdateFlag(GlobalWind)
local Position = Flag:GetPivot().Position
local Rotation = CFrame.lookAt(Vector3.zero, GlobalWind)
Flag:PivotTo(Rotation + Position)
end
UpdateFlag(workspace.GlobalWind)
workspace:GetPropertyChangedSignal("GlobalWind"):Connect(function()
UpdateFlag(workspace.GlobalWind)
end)
This assumes your flag has a WorldPivot of (0, 90, 0)