Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I add strength to a weld that gets rotated by a point?

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

0

Is there a property called Strenght for Weld ? I would say... no. Please explain more cause i don't really know what you want.

0

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?

0

https://gyazo.com/76d8e6c142f9ffaf79fc6f61df01b185 Here is an animator example, See how the arm has position between the two key frames. its kinda like that.

1 answer

Well, I figured it out! So I created a for loop to get each position between Original and position. this I used lerp

for n = 0, 1, 1/(4 - 1) do
	table.insert(list, a:Lerp(b, n))
end

after that, I edit the blend function and create the formal for the intensity and it works.

Gif Link below: https://gyazo.com/0f441015021f8b016cea4e7e83ba4270

This discussion is preserved as it was. New answers, comments, and votes are closed.