# Help with some BodyVelocity [contains helicopter / physics stuff]

So I’ve got a helicopter I’ve been working on lately, and I’ve been wondering how I would set up the dynamic control of it. I was proposing the concept that I would realistically base the movement of the helicopter on the rotor’s power, rather than some sort of jailbreak-ish helicopter control with WASD, appearing less realistic in terms of a helicopter’s physics.

Ideally, the thrust of a helicopter would be situated in the center of mass, and it would lift the helicopter or vehicle with a throttle based control, and the thrust facing upwards could be manipulated so that rotating or pitching the helicopter down at a specific angle could provide forward movement for the helicopter:

Now here’s my problem: I’ve figured it would be best to use BodyVelocity as the other body-movers seem harder to lift a heavy helicopter in the air, but my issue is controlling the BodyVelocity from multiple angles.

Remember that upwards thrust I was talking about earlier? I successfully accomplished implementing the concept into the helicopter’s movement, and it travelled upwards and downwards with ease with the following line of code:

[NOTE: the power is just an integer value which is multiplied by the throttle value, which can range from -50 to 100.)

The problem with the throttle with bodyvelocity is that the thrust can only go upwards (it’s global positioning), so I need help finding solutions on how to fix or re-attempt this concept?

I tried adding another body velocity to move the helicopter forward, but I realised that you can’t exactly use multiple bodyvelocities simultaneously.

6 Likes

Thanks for the offer!

As explained above, I and controlling the rotation of the helicopter in 4 ways:

• The pitch is controlled with W and S
• The turning (facing left and right) is controlled with A and D
• The banking (tilting left and right) is controlled with Q and E
• The throttle (going up and down) is controlled with LShift and LControl

My only issue is with the throttle and getting the helicopter to move! It rotates and turns (all of the first three bullet points are sorted , but that final one is an issue because i’m not sure how to use the throttle to move the helicopter around!

You can contact me on discord if you’d like to investigate further

In general you are talking of a PID-controller using the throttle at an angle to overcome gravity and add thrust in the direction of the rotors, in roblox terms it’d result in the forward and upward vector combined and adding the mass (gravity) as a factor as well. Since Roblox BodyMovers use a similar technique to PID controllers to apply more force as the goal becomes more out of reach you should only need to calibrate the mass with the P (bigger increase over distance) and D (slows down as it gets closer to goal) values that work for you, combining the forward direction with the upward direction ((up vector - forward vector)/2 + forward vector), ideally adding gravity to the mix to pull it down

1 Like
``````local X, Z = (ADown and -1)  or (DDown and 1) or 0, (WDown and -1)  or (SDown and 1) or 0
local UpVel = (ShiftDown and UpVel+0.1) or (CtrlDown and UpVel-0.1))
UpVel = (UpVel<-1 and -1) or (UpVel>1 and 1)

local _, _, _, R00, _, R02, R10, _, R12, R20, _, R22 = Engine.CFrame:components()

local Velocity = Velocity + Vector3.new(R00,R10,R20)*X + Vector3.new(R00,R10,R20)*Z
Velocity = Velocity.magnitude>MaxSpeed and Velocity.unit*MaxSpeed or Velocity

BodyVelocity.velocity = Velocity + Vector3.new(0,UpVel,0)

local Y = (QDown and Y-0.1)  or (EDown and Y+0.1) or Y
Y = (Y<-1 and -1) or (Y>1 and 1)
BodyAngularVelocity.AngularVelocity = Vector3.new(0,0,0)

local Cr = Vector3.new(0,1,0):Cross(Velocity)
Motor6D.C0 = CFrame.fromAxisAngle(Cr,Cr.magnitude*0.1)
``````

Motor6D is connected from engine to a part and that part is welded to the rest of the helicopter

5 Likes

Don’t forget to calculate for drag, or else your helicopter will seemingly have infinite acceleration

1 Like

That’s another concern, I was thinking of limiting it to a certain velocity.

You would typically limit the amount of thrust gained from the throttle, as if the throttle is fully open. Drag should be rather insignificant though, it is a constant factor that basically nullifies at higher thrust values. In real life it would definitely be a concern, but in games you generally cater to what ‘feels right’ rather than what ‘mimics real life as best as possible’. This goes for simulators used to train pilots as well, since when taking as many real factors into account as possible it turns out to be very difficult to get a similar result as real life. (too many factors missing to get the combined realism)

1 Like

No need for drag. I put in MaxSpeed into the calculations and acceleration is always linear. This is because the way he wants to do the controls of the helicopter isn’t realistic.