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

How would one keep an object afloat at a certain Y position?

Asked by 5 years ago
Edited 5 years ago
game:GetService("RunService").Stepped:Connect(function()
    script.Parent.BodyPosition.Position = Vector3.new(script.Parent.Position.X, 92.125, script.Parent.Position.Z)

end)

I feel like this isn't an optimal way of keeping something at a certain Y coordinate. I have no idea how to work the "Body" group of objects, can I get some help?

http://prntscr.com/kwtmc7

In the screenshot provided, the boat floats using the script shown above, I feel like there definitely is a better and more efficient way of doing it than this, since I feel like this will lag the server.

0
as far as i know you can attempt to use body movers, but that uses render stepped, which i guess is the most efficient TreySoWavvy 18 — 5y
0
idk, im noob at scripting mewant_taco 17 — 5y

1 answer

Log in to vote
1
Answered by
shayner32 478 Trusted Moderation Voter
5 years ago

You'd probably want to use a BodyPosition with a MaxForce of v3(0, amt, 0) with a high amount of dampening to make it more stable.

For example, if you wanted your part to hover at the coordinates v3(0, 10, 0), your settings on the BodyPosition could look something like this:

D = 1250, MaxForce = v3(0, 2000, 0), P = 10000, Position = v3(0, 10, 0),

which would result in something like this.

0
Would that allow the part to move around by applying other BodyMovers like BodyThrust? Activatted 47 — 5y
0
Yes, you could apply other forces as well. shayner32 478 — 5y
Ad

Answer this question