Linear Velocity Movement

Hi! I am working on a game that has balloons in it, and I am trying to achieve a balloon flying physics, not something really complex.

The issue is that I am applying a linear velocity to the players character and it does get the job done but it does not match my requirements for the game. I need the player to be able to move around while flying but the linear velocity ( which is applied to the RootAttachment ) doesnt seem to let the player move, I have tried using vector force on the player but it just doesnt move the player upwards and it doesnt do anything.

I need help figuring out how to make the player both fly with the linear velocity ( or some other method ) but also keep the movement of the player ( not jumping just moving around like forward, backwards, left and right )

Try Using Body Velocity’s That Might Fix Your Issue. Linear Velocity’s are Iffy.

I have seen that Body Velocity is deprecated and thats why I avoided using it and the Roblox documentation said I should use Linear Velocity instead. Is it okay to use Body Velocity even tho it is deprecated?

try applying the linear velocity to the balloons instead of the root attachment. Otherwise try just setting the .Velocity or .AssemblyLinearVelocity property of the character

Yes Its Really Okay. I use Body Velocity’s All The Time and It Works For Me Just Fine.

1 Like

Hello!

I discourage the use of old body movers like BodyVelocity and BodyGyro, they are deprecated and can’t be inserted within explorer anymore for a reason. They do still work, but more because of backwards compatibility with the old code.

Mover constraints, AssemblyLinearVelocity and AssemblyAngularVelocity are the way Roblox has been oriented right now.


I’m not completely sure what kind of balloon physics you mean, but I’m assuming it’s the baloon tied to a string that sort of makes the player light and flying.

One way would be to take player’s input and apply the linear velocity according to those values. For example, key code D would apply slight additional velocity on the x-axis relative to the root attachment (to the right).

For the balloon physics I just apply the Linear Velocity directly to the body of the player because the balloon itself is more of an aesthetic, is there any way you could help with the additional velocity and how i could calculate it based on the key pressed? and also would it be compatible with mobile devices too?

Apologies for the slightly late response.

Regarding forward, backward, right and left movement, the easiest way seems to involve the default controls module, which should work for mobile as well.

local Controls = require(player:WaitForChild("PlayerScripts"):WaitForChild("PlayerModule"))
:GetControls()

You can use the Controls:GetMoveVector() to find the directional unit vector relative to the HumanoidRootPart. So W for moving forward would be 0, 0, -1 and so forth.

Direction times length of your choice could be then applied to the linear velocity while keeping the y-axis intact. To illustrate, something like

moveVector = direction * length
velocity.VectorVelocity = Vector3.new(
	moveVector.X, velocity.VectorVelocity.Y, moveVector.Z
)

As for the lifting movement, it again depends on how realistic the physics should be.

First, you’d detect input, such as space bar and left shift on PC and, for instance, ContextActionService buttons for up and down on mobile devices.

For smooth and a tad bouncy lifting, I’m thinking about what @BRicey763 made in the video about pretty nice hover cars. The important part is the way he used two contradicting forces, one pointing upwards and the dampener to adjust the height.

EDIT.

Following the same principle you can actually use VectorForce instead of LinearVelocity for moving around too!

4 Likes

The 13 is just what to multiply the LookVector by as it just gives you the unit direction

I was making a jetpack and this allows me to move in all directions like the ballon from the natural disaster game

local HumanoidLookVector = HumanoidRootPart.CFrame.LookVector * 13

LinearVelocity.VectorVelocity = Vector3.new(HumanoidLookVector.X, 40, HumanoidLookVector.Z)