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

How can I correctly use BodyThrust?

So, I quickly created an engine model. It looks like this:

Engine Image

Inside that engine model there's a part called 'MainPart' - This part contains the BodyThrust.

MainPart Image

I just want my engine to constantly move forwards towards an invisible part in the model called ForcePart. Btw, everything is being welded to 'MainPart'

local bt = script.Parent.BodyThrust -- This script is inside of 'MainPart'
local engine = script.Parent.Parent -- The engine model
local force = 200
while wait() do
	bt.Location = engine.ForcePart.Position -- Setting the location property of the BodyThrust to the location of the ForcePart. 
	bt.Force = Vector3.new(force,force,force) -- Setting the force to 200 on each axis.
end

Now, this should work, but instead the engine spins out of control. It doesn't move forwards like it should. Please help!

2 comments

0

If you want something to move to a specific location, you should use BodyPosition. (Or CFrame.Lerp)

0

I'm working on a hovercraft and was recommended to BodyThrust @RubenKan

1 answer

✓ Accepted answer

The Location property of BodyThrust objects is an offset from the center of the thrust's parent. In other words, this is a location in object space, not world space. As a result, since you set Location to the part's position, it's applying the force really far away from the actual part, depending on your distance from the origin. This is obviously not your intended behavior.

The solution is to just set Location to an empty vector, e.g. Vector3.new(0, 0, 0)

You can read this wiki article to get an overview of all of the BodyMovers.

As RubenKan stated in the comment, since you are wanting to move the engine to move towards a specific point, consider using a BodyPosition. It's more suited for what you want it to do.

1 comment

0

Thanks, it's working like a charm now! I ended up creating a rocket powered car with it. Also, huge honor to meet you :)

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