How to make the character to levitate in the air without need of moving it?

Hi I want to create a script that makes the character stay levitating in the air and not go up and down.

I looked for some solutions in the forum but no success either they wasn’t what I wanted either they used deprecated roblox api like BodyForce, suggestions like BodyPosition etc.

If possible the character should move in the air, but only when the keys are pressed.

Im having trouble with the new roblox api like AngularVelocity. It requires Attachment which makes me attach an anchored part in the air to the player, but again its not what I want. The player needs to move.

Can someone with more experience help me please?

2 Likes

Can you help me with that guys? Anyone?

animations might be the way to go honestly, it won’t affect the movement any, although im not smart with physics so, if that doesn’t answer the question, sorry!

Though it is deprecated, BodyPosition will accomplish exactly what you need!

Simply set a MaxForce of Vector3.new(0, math.huge, 0), and then set your BodyPosition’s Position Y height to whatever height you’d like to player to be off the ground. For example, a position of Vector3.new(0, 20, 0) will position the player 20 studs in the air.

Keep in mind you’ll need to do something like raycasting to keep the player’s height consistent on different elevations of ground, as well as making sure there isn’t a roof over their head when they start levitating, but this should help you get started.

1 Like

I though about that variant and it’s logic but I forgot to mention I need the player go up when the for example E is pressed to avoid being shooted by other players. But it should stay at the level he was when the E key is released.

Probably something like fly in admin cmds and animation will do the stuff but I want to code it on my own. Thanks for the idea Btw. I totally or got about the animations.

Thank you for the suggestion but I’m trying to not use deprecated classes because roblox will remove them at some time and then all my code connected with it will be broken :slight_smile:.

Do you know if there is a good replacement of bodyPosition?

Thank you all guys for trying to help me.

I found the answer in one YouTube video.

I don’t know if I can post it here I will try to help you see how to do it with align orientation and vectorForce.

The solution

From what I know you can simply use HopHeight, that’d it’s use from what I know, di something like:

local function onEvent(character)
         local humanoid = --find humanoid path
         if humanoid then
               humanoid.HopHeight = --whatever
         end
end

Roblox will likely not remove BodyPosition. Deprecated means they’ve stopped supporting don’t recommend said item for newer work because there’s likely a more improved method of accomplishing the same task, but in this case BodyPosition works great because it requires no attachments, and has just the functionality you need.

If you’re curious why the older BodyMovers were deprecated, from what i can tell it was because the newer AlignPosition, AlignOrientation allow for more customization, though they require more setup which is why I suggested BodyPosition.

Glad you found a way that worked for you though.

Edit: I feel I should mention though I only suggest this method because of your seemingly simple use-case. If you plan on using this for the long term / need more customization definitely go with AlignOrientation or AlignPosition. If the older BodyMovers ever break / aren’t supported by a newer physics update, they’ll likely never get fixed so it’s always a good idea to use the most up to date content.

1 Like

If only the new physics mover were as easier to setup. The old ones are literally four properties that easily get their job done without attachments.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.