Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Could someone explain this math problem in depth?

Asked by 5 years ago
local BV = Instance.new("BodyVelocity")
BV.Parent = script.Parent
BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
BV.Velocity = workspace.Part.Position.Unit*50

This script has the velocity a bit offset; however if you change line 4 to this:

local BV = Instance.new("BodyVelocity")
BV.Parent = script.Parent
BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
BV.Velocity = (workspace.Part.Position - script.Parent.Position).Unit*50 

it works.

Why does the bottom one work but not the top one? What is happening at the bottom one?

1 answer

Log in to vote
0
Answered by 5 years ago

On the top it finds the unit in the workspace and the unit is multiplied by 50 so the BV.Velocity is 50 on the bottom it takes the position of the part and subtracts it by the scripts parents position then multiplies it and get that as the BV.Velocity

Ad

Answer this question