I figured that from a game programming perspective, a drone simulator is not too difficult but I didn’t find a cool open source web version. Also, I have really important things to take care of, so I have a lot of procrastination energy and decided to try creating one
Problem is that I have zero flying experience, just played DRLSim a little, so it would be nice if experienced people could give feedback on the physics and maybe help tune everything (once I actually have proper physics).
Right now everything is just hacked together and mock ups (and there is also only gamepad control), I want to see if people are interested in this. I’d also appreciate any map contributions, right now I just downloaded stuff from sketch fab that looks somewhat interesting.
Looks like a great start! I don’t have a gamepad on hand, so it’s hard to test. I suggest you implement basic keyboard controls asap, just so folks can see if it’s worth plugging in a gamepad.
Now added keyboard and mouse controls and also orbit controls. Instructions are on the readme and a list of further todos that I see is also there. Open for further suggestions, including what to prioritize.
Nice. Its pretty usable with keyboard. I suggest adding the arrow keys for lefties, as well. I learned that the hard way.
I’d add a raycast from the drone to the desired camera point, and then move the camera to hit distance / 2, to prevent the camera clipping.
Shadows would help this a bit too.
And.. needs sound! You can use audio nodes / oscillators to make a drone sound.. but takes a bit of fiddling. You might be able to fake it with a looping sample, but dynamic motor sounds like this are fun to make with oscillators.
Thanks for your suggestions! Was an angry mob of lefties banging at your door because of some WASD game you made? I will also implement the camera stuff.
I’d prefer non-fiddly solutions but for a looping sample I need… a looping sample. The thing is, I will actually need four different loops for the four props because they need to play at different speeds and I want to prevent accidental syncing so I don’t have this phaser effect from racing games. I only find recordings of all four props at the same time, if someone has a drone and could send me a long (maybe 10 minutes) recording of just a single propeller with constant rpm, that would be awesome.
Heh! I didn’t make the suggestion to move away from WASD, but I was thinking it. We used WASD in the 1980s and I hated it. Since then, the mouse has largely replaced the keyboard as the primary controller for PCs and allows so much better control over inputs. So I am surprised that people (especially younger people) seem to cling to WASD.
But perhaps it all has to do with the fact that, yes, I am a lefty.
I mocked up an example of using THREEJS+WebAudio Nodes/Oscillators/Filters to make drone prop sounds.. you could plug your sim into the oscillators to change pitch of the motors etc.
It created one set for each motor, but you could also combine/mix them all together into one audio source..
I didn’t spend any time tweaking the oscillators + filters but i bet you can find some values that will be really close to a drone.
Tweak the maths in the:
// Update Audio Params based on Throttle
synthNodes.forEach((node, i) => {
I just realized that I am working on a project which may be similar - but involving a helicopter rather than a drone. Right now, this is a pretty standard MD500 helicopter which uses mouse controls: the mouse controls direction (cyclic), the mousewheel controls thrust (collective) and the left/right buttons controls the yaw (tail rotor). Hit “O” (previously “S”) for sound (which is my favorite part).
I plan to modify my helicopter flight module to turn this into an acrobatic helicopter - similar to a drone - where you can fly upside down, etc.
So if there is anything I am doing that you find useful, let me know.
@manthrax thanks for the demo! I was already thinking there can be some “cyber”-levels where this style fits.
For the main game I want actual recordings tho, and I even managed to get my hands on some. Still needs some work but there will be sound soon. @phil_crowther thanks! It seems arrows, A and D and mouse all control roll. In the code it says X and Z control yaw, but it seems to be a bit buggy. I will let you know if I need some help!
I had forgot that I had left some keyboard commands in. Yes, all those keys appear to have some impact on direction of flight. But it looks like the mousewheel in the only way to change throttle. (EDIT#2: You can use keys Q and E to change throttle. For direction, you can use A and D to bank, W and S to pitch, or you can use the arrow keys)
I should have explained, in a little more detail, the flight dynamic. In a bank or pitch you have to increase thrust to maintain altitude. An experienced pilot will do this automatically. So this simulation puts you in the persona of an experienced helicopter pilot. This is not conducive to acrobatics since there are situations where the angle of pitch or bank is so great that there is simply not enough thrust available to maintain altitude. We avoid this problem by limiting the angle of bank or pitch. This is okay in general because a helicopter is supposed to be a stable flight platform that does not perform loops or rolls. This also means that you do not use pitch to change altitude (like in an airplane), but to speed up or slow down. You use the mousewheel to change altitude. If you watch helicopter videos, you will see that this fits with how helicopter pilots describe how the controls work - they use collective to change altitude and cyclic to change direction.
It appears that many drones have this kind of operator-assist to maintain altitude when the drone is pitched or banked. If so, they may behave exactly like this simulation.
But if you want to create an acrobatic helicopter, you need to unsimplify things. In this case, you need to have direct control over thrust so that when you pitch up to perform a loop, you can increase thrust (which is mostly directed straight down relative to the helicopter) to cause a climb. This also means that, if you bank, you are going to have to manually increase thrust to maintain altitude. So that is what I plan to do.
I expect that some drones (like racing drones) also have some auto-stabilizers disabled for the same reason.
I am not sure which type of drone flight model you want to use. I already have the module for stable non-acrobatic flight. I am working on the module for acrobatic flight.
Once I have all the basics done, I’m going to implement unassisted (acro) mode, optional altitude control, optional tilt stabilization and optional angle limiting so people an mix and match. But since this is the most fun part to work on, I’m not gonna copy that from somewhere
My modules compute rotation using liinked objects (a trick which you might find preferable to using Napier’s rules). See this example.
The airplane module computes acceleration due to thrust, lift, drag, and gravity. I found helicopters a bit confusing regarding things like excess thrust, so I used values from published resources to interpolate the values at various speeds. For the acrobatic module, I plan to try using a version of the airplane module (where lift is generated by thrust) and see what happens.
Like you, I plan to have a lot of fun with this. When we are done, we can compare notes!
You can press R on keyboard or R on gamepad (button 5, Hardware Tester) repeatedly to warp back in one second steps. I am planning on implementing anti-turtle mode but until then you have to step back.
You can also hit space to switch between fpv und tpv camera.
I try to keep the readme up to date, it should all be in there.