Body Thrust Not Making Part Go In The Direction It Is Facing

I am currently working on a realistic plane system, but I’m already running into issues. As you can see from this gif, the plane is not going in the direction in which it is facing.

https://gyazo.com/8350bd787f888b1c4c0719c135534088

I am not sure why it is rotating, but even then, the plane does not go in the direction that it is facing. This is my code:

local function SetLeftEnginesForce(Force)
	for _,Engine in pairs(LeftEngines:GetChildren()) do
		if Engine then
			if Engine:IsA('BasePart') then
				local EngineThrust = Engine:FindFirstChild('EngineThrust')
				if EngineThrust then
					EngineThrust.Force = Engine.CFrame * Engine.CFrame.lookVector * Force
				end
			end
		end
	end
end

local function SetRighttEnginesForce(Force)
	for _,Engine in pairs(RightEngines:GetChildren()) do
		if Engine then
			if Engine:IsA('BasePart') then
				local EngineThrust = Engine:FindFirstChild('EngineThrust')
				if EngineThrust then
					EngineThrust.Force = Engine.CFrame * Engine.CFrame.lookVector * Force
				end
			end
		end
	end
end
2 Likes

BodyThrust uses local space relative to the part it’s in, the direction you are giving is in worldspace. I think you meant to use BodyForce.

1 Like

This doesn’t fix it. I need it to make the BodyForce or BodyThrust to make it go in the direction its parent is facing.

image

Using your method makes it do this:
https://gyazo.com/8d7dec5c0073ba24ebfc99a6db75839c

1 Like

Didn’t you meant to write;

EngineThrust.Force = Engine.CFrame.lookVector * Force

If you set that as the .Force property of a BodyForce your plane should move in the direction of the Engine’s lookvector.

Now it doesn’t move at all.

EDIT: Force is a number

SetLeftEnginesForce(1000)
SetRighttEnginesForce(1000)
1 Like

Increase the Force variable; the length of the vector determines the Force applied. Your plane looks heavy, a regular 2x1x4 brick starts to move at around 300-400.

Oh yeah, my bad, thanks! Another thing that I am having an issue with is with BodyGyros. I am trying to make it rotate by 45 degrees relative to the parts position and orientation.

EDIT: Like this: https://gyazo.com/a24153c2fe66d9d36a6f67ea0832227b

1 Like

You’ll want to alter the .CFrame property of the BodyGyro for that. For a 45 degree rotation on the Y-axis (I think that’s what the gif is showing?) you’d set it to;

BodyGyro.CFrame = CFrame.new() * CFrame.Angles(0,math.pi/2,0)

To prevent any rotation in all axes, you’d set the MaxTorque Vector to a high value on all axes;

BodyGyro.MaxTorque = Vector3.new(4e5,4e5,4e5)

The exact max torque values to use depend on the forces exerted on the object.

1 Like

That doesn’t work. It just makes it look upward. I need it to be able to do something like this:

1 Like

I need it to rotate along a certain axis so that it rotates vertically no matter its position or orientation.

1 Like

You should be able to accomplish this with BodyAngularVelocity.
http://robloxdev.com/api-reference/class/BodyAngularVelocity

Actually let me be more specific.
If a player can sit in the plane to control it, you can use a VehicleSeat and BodyAngularVelocity to rotate the plane. The Vehicle seat has a property that detects which way the player wants to go. According to the Wiki, 1 = right, 0 = straight, -1 = left. You can do something like this for the rotation

local speed = 100 BodyAngularVelocity.AngularVelocity = Vector3.new(0, (speed * -(seat.Steer)),0)

Just make sure the Torque and P property are adjusted correctly for the size of the plane.

You can also use a BodyGyro for dampening but just set the CFrame to the CFrame of the primaryPart of the plane.

Hope this helps!

That wouldn’t work because BodyAngularVelocity doesn’t have a goal so it would just keep going in that direction. Usually this would work with things like the Crazyman32 plane kit, but mine is going to control differently.

EDIT: I have made the code for setting the CFrame of the Gyro to CFrame.Angles(Elevator.CFrame.upVector * 45)
But I get the error:
bad argument #3 to 'Angles' (number expected, got no value)

1 Like

This is because CFrame.Angles only takes numbers but here you are giving it a vector.
Try doing CFrame.Angles(lookVector.X, lookVector.Y, lookVector.Z)

Thanks for the help, but I am scrapping doing it this way.

2 Likes

You should know that the fact you found a different way is not the solution to the topic. Threads in development support are meant to be an archive for anyone in the future to find the answer to their question.

If @Eventive’s method works, then that is the solution to this thread’s question.

3 Likes

It didn’t work.

1 Like

What way are you using then? I’m not sure what CM32’s Plane Kit consists of but you could use BodyVelocity and BodyAngularVelocity (using the method I originally replied with).

Using the Velocity you can set the Velocity using the VehicleSeat’s Throttle property and times it by a speed, the speed can be a variable that changes if you want it to accelerate over time.

This would make the plane controllable and you can add in some special code to act like a normal plane.

If you’ve already settled on a way, then disregard this, it’s just an option :slight_smile:

EDIT:
Using a VehicleSeat would only partially work for airplanes. You would have to manipulate it a bit to add up/down controls. Possibly using ContextActionService.