Still have questions? Join our Discord server and get real time help.

Log in to vote

0
I am trying to send a part in a diagonal direction using a BodyVelocity. The BodyVelocity only has:

rightVector (can be used to send a part left or right)

local BodyVelocity = Instance.new("BodyVelocity") BodyVelocity.Velocity = (HumanoidRootPart.CFrame.rightVector * 50) BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge) BodyVelocity.Parent = Part local BodyVelocity = Instance.new("BodyVelocity") BodyVelocity.Velocity = (HumanoidRootPart.CFrame.rightVector * -50) BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge) BodyVelocity.Parent = Part2

upVector (can be used to send a part upward or downward)

local BodyVelocity = Instance.new("BodyVelocity") BodyVelocity.Velocity = (HumanoidRootPart.CFrame.upVector * 50) BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge) BodyVelocity.Parent = Part local BodyVelocity = Instance.new("BodyVelocity") BodyVelocity.Velocity = (HumanoidRootPart.CFrame.upVector * -50) BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge) BodyVelocity.Parent = Part2

and a lookVector (can be used to send a part forward or backward)

local BodyVelocity = Instance.new("BodyVelocity") BodyVelocity.Velocity = (HumanoidRootPart.CFrame.lookVector * 50) BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge) BodyVelocity.Parent = Part local BodyVelocity = Instance.new("BodyVelocity") BodyVelocity.Velocity = (HumanoidRootPart.CFrame.lookVector * -50) BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge) BodyVelocity.Parent = Part2

What would I need to work out so that the part can be sent in a direction diagonally from the player? I tried finding the distance between the lookVector and the rightVector...only to realise that it is pointless.

0

why are you using multiple bodyvelocities rad_n00b 35 — 2mo

0

I'm not. They are just to show that I know how to use them Despayr 148 — 2mo

Log in to vote

1
`BodyVelocity.Velocity`

is a `Vector3`

. You could use a "diagonal" vector by using a combination of it's components:

BodyVelocity.Velocity = Vector3.new(1, 1, 1) -- moving 1 on each axis, creating "diagonal" like movement (if that was what you meant)

But you might want to change it to a *unit vector* so a magnitude can be explicitly set and adjusted:

BodyVelocity.Velocity = Vector3.new(1, 1, 1).Unit * magnitude

`LookVector`

, `UpVector`

, and `RightVector`

are components that belong to `CFrame`

s. They are *unit vectors* of where the CFrame looks at, the "top" of the CFrame, and the "right" of the CFrame respectively, all relative to it's orientation. If you mean to have a BodyVelocity.Velocity that is relative to a part's orientation you could use the `VectorToWorldSpace`

of CFrames:

BodyVelocity.Velocity = part.CFrame:VectorToWorldSpace(Vector3.new(1, 1, 1).Unit) -- turn "diagonal" vector to have a relative orientation to the part's CFrame. Equivalent to UpVector + RightVector - LookVector

I can't explain everything here so look up Vector3s and CFrames.