How do I Start to Script a drivable Helicopter?

I have made a helicopter model that gets fully welded and has a vehicleseat, but it does not work as it is a helicopter, not a car. I want this helicopter to use instances such as angular velocity/linear velocity, or if there are other methods that work using physics.

How would I script this? Keep in mind I want it to depend on the vehicle seats steer and throttle value. I want this to be at least mobile compatible.

The blade is connected with a hinge and does spin with sounds when a player enters the vehicleseat. Although, it has no controls.

So, where do I start?

5 Likes

You can first add a LinearVelocity into your helicopter and set it to an attachment. Tweak the force values until you’re comfortable with the speed. You can modify the values of the LinearVelocity based on the throttle value and steer value of that seat.

4 Likes

Where should I place the linear velocity on the helicopter? I want to make sure it is easy to control.

5 Likes

It shouldn’t matter, just make sure you set up a PrimaryPart for the helicopter, add an attachment in that, and connect the LinearVelocity’s attachment to the attachment you added.

4 Likes

The primary I decided was the floor.
image
I made linear relativeto to attachment0.

but the helicopter is not stable

code:

local function Check()
	if VehicleSeat.Steer == -1 then
		MainLinearVelocity.VectorVelocity = Vector3.new(MainLinearVelocity.VectorVelocity.X,MainLinearVelocity.VectorVelocity.Y,-MaxLinearVelocity)
	elseif VehicleSeat.Steer == 1 then
		MainLinearVelocity.VectorVelocity = Vector3.new(MainLinearVelocity.VectorVelocity.X,MainLinearVelocity.VectorVelocity.Y,MaxLinearVelocity)
	elseif VehicleSeat.Steer == 0 then
		MainLinearVelocity.VectorVelocity = Vector3.new(MainLinearVelocity.VectorVelocity.X,MainLinearVelocity.VectorVelocity.Y,0)
	end
	if VehicleSeat.Throttle == 1 then
		MainLinearVelocity.VectorVelocity = Vector3.new(MainLinearVelocity.VectorVelocity.X,MaxLinearVelocity,MainLinearVelocity.VectorVelocity.Z)
	elseif VehicleSeat.Throttle == 0 then
		MainLinearVelocity.VectorVelocity = Vector3.new(MainLinearVelocity.VectorVelocity.X,0,MainLinearVelocity.VectorVelocity.Z)
	elseif VehicleSeat.Throttle == -1 then
		MainLinearVelocity.VectorVelocity = Vector3.new(MainLinearVelocity.VectorVelocity.X,-MaxLinearVelocity,MainLinearVelocity.VectorVelocity.Z)
	end
end

check function is ran when throttle or steer change
main linear velocity is this

4 Likes

This is where AlignOrientation comes in. You can use it to stabilize your helicopter. Good work by the way.

5 Likes

The documentation is very confusing and I do not understand what properties to change, but I put it inside the primarypart
image
Now what do I do?

2 Likes

Make it one attachment, and set the CFrame of the AlignOrientation to the desired Orientation. Make sure to change the forces too.

For example:

AlignOrientation.CFrame = CFrame.new(0, 0, 0) -- Will attempt to be this orientation
2 Likes

Do I change the attachments oreintation based on the steer/throttle, or would it be velocity then when I change this I make alignoreintation to the CFrame of attachment0?

2 Likes

You should only be setting the AlignOrientation’s CFrame, just try out some values and see how it works. The best way to figure out what you want is to test it.

2 Likes

When setting the AlignOrientations CFrame, how do I make the CFrame on the AlignOrientation go to where I want the helicopter to rotate?

2 Likes

Matters on how your helicopter is originally orientated.

I’m guessing you’ll either have to change the X or Z values in the CFrame.

2 Likes

I still do not understand well how to do it

2 Likes

Just test around with it, I don’t know the exact values you’ll need.

Information you might need:

2 Likes

Here’s a video on BodyGyros (AlignOrientation replaced them, but it should be fairly similar to implement):

2 Likes

I put the AlignOrientation mode to oneattachment, and now the helicopter is driveable, but can not rotate, but now that this is driveable, how would I make it rotate ? By rotate I mean rotate the body, since it can already steer

2 Likes

Set the AlignOrientation’s CFrame to your desired tilt.

2 Likes

Is the cframe on align orientation dependent on its axis or the words axis?

1 Like

Correct.

2 Likes

Sorry, I read that wrong, I’m fairly sure the orientation is dependent on a global axis, and the position isn’t taken into account.

The documentation is a bit difficult for me to understand too lol:

2 Likes