I have all the leafs pointing away from the point, but what I am trying to do is make it have an Intensity to each leaf and when set to 0 it goes back to its original position, and 1 as its strongest point towards. How would I ramp/strength this.
Here is the code i have so far:
local leaves = script.Parent.Leaves
local leavesData = {}
local windPosition = game.Workspace:WaitForChild("WindDirection")
function grabData()
for _, leaf in pairs(leaves:GetChildren()) do
local leafWeld = leaves.Part.Weld
if not leavesData[leaf] then
leavesData[leaf] = {
Weld = leafWeld;
C0 = leafWeld.C0;
}
end
end
end
function blend(orginal, position, intensity) -- instensity is from 0 - 1
--[[
0 is orginal
Anything between is the strength to position
position is 1
]]
local fixedPosition
fixedPosition = position
return fixedPosition
end
grabData()
while wait() do
local Intensity = windPosition["Intensity"].Value
local TopDirection = windPosition["Top"].Value
for _, leaf in pairs(leaves:GetChildren()) do
local data = leavesData[leaf]
local windDir = (windPosition.Position - leaf.Position).unit
local squashedLookVec = Vector3.new(
windDir.X,
TopDirection and (windDir.Y) or 0,
windDir.Z
).unit * Intensity
data.Weld.C0 = blend(
Vector3.new(data.C0),
CFrame.new(Vector3.new(data.C0), Vector3.new(data.Weld.C0) + squashedLookVec),
Intensity
)
end
end
Here is picuture of what I'm trying to do: http://prntscr.com/orbtvj

3 comments
Is there a property called Strenght for Weld ? I would say... no. Please explain more cause i don't really know what you want.
Its kinda like a blend between the Original Position and the position from the point of wind, i wanna use the intensity to determine the strength of the weld kinda like a blend, Its almost like key frames in the animator. i add in the code a function called Blend. check that out, have you seen the image?
https://gyazo.com/76d8e6c142f9ffaf79fc6f61df01b185 Here is an animator example, See how the arm has position between the two key frames. its kinda like that.