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

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

Asked by
uhSaxlra 181
5 years ago
Edited 5 years ago

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

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

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
0
Works like a charm, thank you. Also is it possible to add more vectors? I'm assuming so. uhSaxlra 181 — 5y
0
Sure, as many or few as you need LukeSmasher 619 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

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

0
Its an airplane and Im trying to make spoilers uhSaxlra 181 — 5y

Answer this question