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

How to move a BodyVelocity move in two different directions at once?

What I'm trying to do is have a part move forward, and down at the same time. The problem is that I want it to move forward in the direction the part is facing, same thing with the down force.

This is part of an airplane.

script.Parent.BodyVelocity.Velocity = (script.Parent.Main.CFrame.lookVector*Speed) -- The forward speed

2 answers

✓ Accepted answer

Simply add the two Vector3s representing your velocities together:

local forward = Vector3.new(0, 0, 10)
local down = Vector3.new(0, -10, 0)

BodyVelocity.Velocity = forward + down

In this example, the sum of the two Vector3s will create a velocity of Vector3.new(0, -10, 10).

Or more specifically to your case:

local forward = Main.CFrame.LookVector * speed
local down = Vector3.new(0, -10, 0)

BodyVelocity.Velocity = forward + down

2 comments

0

Works like a charm, thank you. Also is it possible to add more vectors? I'm assuming so.

0

Sure, as many or few as you need

CFrame.lookVector contains 3 values so obviously you cant change the entire velocity to the CFrame lookVector , you can only change x and z, y you have to change manually since the humanoidrootpart's lookvector will always be -0 unless you angle the body somehow

1 comment

0

Its an airplane and Im trying to make spoilers

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