Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Physics [RELEASED] Silantro Flight Simulator

Discussion in 'Tools In Progress' started by Oyedoyin1, Mar 20, 2018.

?

Which is better in terms of "user-friendliness" and "performance"

Poll closed Aug 13, 2018.
  1. 1 giant script

    0 vote(s)
    0.0%
  2. Multiple smaller scripts

    15 vote(s)
    100.0%
  1. Robin_Hilliard

    Robin_Hilliard

    Joined:
    Nov 5, 2020
    Posts:
    2
    Hi just a quick noob question before I purchase, is it possible to simulate tethered aircraft like kites or control line aircraft by combining your asset with other physics libraries and if so, which physics library would be the best choice?

    Thanks,
    Robin
     
  2. Oyedoyin1

    Oyedoyin1

    Joined:
    Oct 30, 2016
    Posts:
    915
    Sure, Robin. The aircraft is just a normal rigidbody with colliders and force-generating scripts



    For the tether system, I'll suggest this: https://assetstore.unity.com/packages/tools/physics/obi-rope-55579...it seems to have a variety of rigidbody pull samples which will help with the setup.

    Lemme know if you need anything during the setup
     
    Robin_Hilliard likes this.
  3. Oyedoyin1

    Oyedoyin1

    Joined:
    Oct 30, 2016
    Posts:
    915
  4. Oyedoyin1

    Oyedoyin1

    Joined:
    Oct 30, 2016
    Posts:
    915
  5. Robin_Hilliard

    Robin_Hilliard

    Joined:
    Nov 5, 2020
    Posts:
    2
    Hi Oyedoyn,

    Thanks, I've bought the package and I'm working on setting up a very simple demo of an Aerofoil (I selected horizontal stabiliser because I want to control the elevator later on) connected to a pole via a cable (just a rigid body cylinder, I tried the ropes but more than I need for this at the moment as cable will always be under tension) with two configurable joints.



    My next question is whether I can use the aerofoil mesh to render the aerofoil somehow. Looking at the examples I see you had some nice mesh assets for the Tucano etc but I'm really just trying to use this as a physics simulation sandbox and so high fidelity meshes aren't important for me. As a complete noob I tried adding a mesh render to the aerofoil but it had no effect.

    Cheers,
    Robin
     
    Oyedoyin1 likes this.
  6. Oyedoyin1

    Oyedoyin1

    Joined:
    Oct 30, 2016
    Posts:
    915
    To make things easier, why not use one of the demo aircraft for a base test since it already contains everything you need to fly. Take the A-29 demo, here's how to make it a glider
    1. Set the empty and maximum weight on the controller to that of your glider
    2. Change the engine type to "Unpowered"
    3. Delete the "Engine System" gameobject and boom....you have a glider :)

    Yes, you should be able to generate a mesh from the aerofoil but I think it'll be a little stressful. The current method I'm using is to draw connecting gizmo lines based on the plot vector points


    Every point in the image is marked and stored, the major issue you're going to run into is the organization of the points as you'll need the vertex vectors in the right order. Here's a snippet about mesh generation: http://answers.unity.com/answers/459796/view.html

    Another thing you can do is use primitive meshes like cylinders and boxes for wings, that'll be easier and less performance intensive.
     
    AlanMattano and Robin_Hilliard like this.
  7. Oyedoyin1

    Oyedoyin1

    Joined:
    Oct 30, 2016
    Posts:
    915
  8. Oyedoyin1

    Oyedoyin1

    Joined:
    Oct 30, 2016
    Posts:
    915
  9. Oyedoyin1

    Oyedoyin1

    Joined:
    Oct 30, 2016
    Posts:
    915
    Testing out some high roll rate aircrafts to observe stability at Unity's angular velocity limit

     
  10. cspann

    cspann

    Joined:
    Dec 12, 2019
    Posts:
    1
    Large Scene Flight Simulator

    This is a bit of a larger topic, as it's a Unity issue, but I'm curious if anyone has come up with a good solution for Unity's shake/jitter in large scale flight simulation.
    I've been building out my scene with Silantro, and I'm in the cockpit position. The farther the aircraft moves from the origin, the more I see a shake, starting at around 5km. When you get to 20km or so, every object in the cockpit is bouncing so wildly, I can hardly read the instruments. Apparently, this has to do with the size limitations of floats and the loss of precision as physics/camera calculations are made.

    Side note - if you're in the 3rd-person camera position and relatively far from the aircraft, the jitter is not (too) noticeable.

    Here's some info about the root cause and some of the symptoms:
    The best solution I've been able to implement so far is one that's included in that first post - "chunk loading".
    My scene can be broken into separate flight stages - take-off, transit, mission, landing - and the user can jump to each of these. When that happens, I reposition the aircraft close to the origin, and show the terrain/objects pertinent to that stage. The aircraft stays relatively close to the origin, and thus no jitter.

    The big problem with this, of course, is the use case of going through the whole sim without stopping or jumping. I thought about creating an edge boundary that would function like a wormhole to achieve the same end of going from stage to stage, but changing the terrain would not be visually seamless. It would definitely have to be a blatant "feature" (not a bug) that the user could readily understand. Not the worst thing, but not the best...

    Other general ideas across the forums have included scaling down all the models or moving the terrain instead of the player. Not super feasible with a nice physics-based system like Silantro.

    Any other thoughts or success stories?
    Thanks!
     
    Oyedoyin1 likes this.
  11. Oyedoyin1

    Oyedoyin1

    Joined:
    Oct 30, 2016
    Posts:
    915
    Actually, the "Moving terrain" idea is what I use :) In fact, the Google Maps SDK for Unity uses a similar idea of repositioning the world coordinates of the scene objects to keep the player (aircraft/camera) distance from the origin below the set threshold value.



    Google SDK: https://cutt.ly/mhWcs21

    Here's the code source I use: http://wiki.unity3d.com/index.php/Floating_Origin.

    The main issue I think might come up is moving a scene with high object counts, but I believe the code can be optimised to improve its performance or probably the scene objects can be batched to make the repositioning more efficient.

    There's this other solution that Brian came up with about performing some magic with the aircraft cockpit but I can't find it again. I'll link it here once I do.
     
    cspann likes this.
  12. blacksun666

    blacksun666

    Joined:
    Dec 17, 2015
    Posts:
    214
    One option but more complicated is to have a camera that is used to display the inside of the cockpit and keep the cockpit at the origin (it could also include the parts of the plane that are visible through the cockpit windows too). Mask this so that it isnt drawn by the camera used to traverse the scene. So you have one camera that 'sees' the inside of the cockpit which never moves and a second camera that 'sees' whats outside the plane. Then overlay one camera view over the other with the cockpit camera having a higher precedence than the world camera. You can combine this with the moving origin on the world/world camera and get away with larger values before you need to shift everything.
     
    cspann and Oyedoyin1 like this.
  13. RoyceIam

    RoyceIam

    Joined:
    Oct 18, 2019
    Posts:
    2
    Hey there! Fantastic work on the flight simulator! I just purchased the asset and I was wondering if you have any VR specific scenes that would be already configured for touch controls of the control stick. I'm having some issues getting values to move from an external joint script to then be used as an input. Thanks for any help!

    Royce
     
    Oyedoyin1 likes this.
  14. Oyedoyin1

    Oyedoyin1

    Joined:
    Oct 30, 2016
    Posts:
    915
    H
    Hi,

    Send me an email, there's a project that should help you get things going
     
    CrypticColza1971 likes this.
  15. RoyceIam

    RoyceIam

    Joined:
    Oct 18, 2019
    Posts:
    2
    Email sent. Thanks!
     
  16. Oyedoyin1

    Oyedoyin1

    Joined:
    Oct 30, 2016
    Posts:
    915
  17. tgamorris76

    tgamorris76

    Joined:
    Apr 24, 2013
    Posts:
    292
    Quick question, i noticed you had a demo of a test with oculus quest. Does this support full vr?
     
    CrypticColza1971 likes this.
  18. Oyedoyin1

    Oyedoyin1

    Joined:
    Oct 30, 2016
    Posts:
    915
    Yes, It does

     
  19. tgamorris76

    tgamorris76

    Joined:
    Apr 24, 2013
    Posts:
    292
    Kool, sorry but another question, is there an AI solution included or is there a third party AI solution you can reccomend?
     
  20. Oyedoyin1

    Oyedoyin1

    Joined:
    Oct 30, 2016
    Posts:
    915
    I'm working on my own AI solution. The Autopilot system which allows you to supply flight variables to the aircraft is done:


    Work is still going on with the full Autonomous mode where the aircraft can take off (Done, they can currently do that), fly, and land all on their own.
     
    CrypticColza1971 likes this.
  21. tgamorris76

    tgamorris76

    Joined:
    Apr 24, 2013
    Posts:
    292
    Nice. will be getting this whilst its still in the sale
     
  22. Oyedoyin1

    Oyedoyin1

    Joined:
    Oct 30, 2016
    Posts:
    915
    Send me an email once you do.... So I'll send you the VR project :)
     
  23. CrypticColza1971

    CrypticColza1971

    Joined:
    Apr 9, 2016
    Posts:
    17
    Hi I love the VR Pitts Special, but would also love for there to be a specific project with any of the helicopters ready to rock for people that have bought the Rotary Wing Asset. You have been very helpful so far, but I am not very technical with unity and having the Project Template ready to go for the helicopter also would be amazing! Great work on the asset, the autopilot should be good also. Col
     
  24. Oyedoyin1

    Oyedoyin1

    Joined:
    Oct 30, 2016
    Posts:
    915
    You know what's funny? The first project to get VR controls was the rotary system


    It was from there that I ported the controls over to the fixed system.
    I'll try and work out a VR demo with the R-22
     
    motuproprio3000 likes this.
  25. motuproprio3000

    motuproprio3000

    Joined:
    Oct 1, 2016
    Posts:
    6
    Hello,
    the VR Demo Scene are included in the packages you sell (Flight Simulator Toolkit&Helicopter Simulator Toolkit)?

    Thanks
     
  26. Oyedoyin1

    Oyedoyin1

    Joined:
    Oct 30, 2016
    Posts:
    915
    No no. The VR demo scenes aren't included in the base package.

    Some of the VR scripts have references to the Oculus SDK and that will generate errors for people who don't need the VR functionality. That's why I send the VR project separately

     
    motuproprio3000 likes this.
  27. motuproprio3000

    motuproprio3000

    Joined:
    Oct 1, 2016
    Posts:
    6
    Thanks for the replay
     
  28. Oyedoyin1

    Oyedoyin1

    Joined:
    Oct 30, 2016
    Posts:
    915
  29. skiwee

    skiwee

    Joined:
    May 30, 2020
    Posts:
    32
    Hey, I know you've probably been asked a million times already, but how are the physics being calculated? I am currently using a custom aerodynamics system that treats everything as a 2d surface and uses math to "fake" it having thickness and shape. Since I was looking to upgrade, could you tell me how accurate your flight sim is in terms of physics? Some tests you can do include setting up a plane that actually exists and testing the takeoff / land speeds and distances and compare with the real world test values.
     
  30. skiwee

    skiwee

    Joined:
    May 30, 2020
    Posts:
    32
    Also I did not see turbulence as a feature, but I can make one myself, so the important thing is does the system allow to to apply specific forces on specific points on the plane? How hard would it be to add a wind / turbulence system?
     
  31. Oyedoyin1

    Oyedoyin1

    Joined:
    Oct 30, 2016
    Posts:
    915
    A simple explanation of how the physics works
    1. Javafoil generates the base 2D lift, drag and moment data
    2. The angle of attack is calculated depending on the analysis method selected
    3. The 2D Lift, Drag and Moment coefficient is looked up for each aerofoil panel from the root and tip airfoil data
    4. The coefficients are corrected using 3D transformation methods.
    5. The Lift, Drag and Moment vector for each foil subdivision is calculated and applied to the aircraft at the aerodynamic centre of the panel

    Here's a sample foil output


    Regards the wind, you should be able to add your wind vector to the base wind used to calculate the angle of attack


    If you have the forces calculated you can add them to the aircraft directly as it is a normal rigidbody.

    Lemme know if you have other questions
     
  32. skiwee

    skiwee

    Joined:
    May 30, 2020
    Posts:
    32
    Could I add force to specific panels at the aerodynamic center of those panels?
     
  33. skiwee

    skiwee

    Joined:
    May 30, 2020
    Posts:
    32
    So basically aerodynamics is done with a precomputed LUT with some adjustments.
     
  34. Oyedoyin1

    Oyedoyin1

    Joined:
    Oct 30, 2016
    Posts:
    915

    Yes, You can either add them as new forces or sum them with the base ones
     
  35. skiwee

    skiwee

    Joined:
    May 30, 2020
    Posts:
    32
    Yes, this makes a lot of sense. Adding it to the normal forces of drag, lift, etc would be good. So one aerofoil would be like a wing? And the rudder? Or are these controls surfaces further divided? And does it include full source code?
     
  36. Oyedoyin1

    Oyedoyin1

    Joined:
    Oct 30, 2016
    Posts:
    915
    Yes, each aerofoil is a single flight component (could be a wing, stabilizer, stabilator or canard). Here's what a sample component setup looks like

    1. Wing





    2. Vertical Stabilizer (Showing the Rudder Controls)


     
  37. skiwee

    skiwee

    Joined:
    May 30, 2020
    Posts:
    32
    Thanks for showing these. Looks good! Can wings also have trim(aileron trim)?
    So that basically means when I want to apply more specific forces I apply it to a whole wing right? If i wanted to add on directly to each surfaces default forces that is. Another way I could do it is create my own points on the wing surface and apply forces on those points directly to the plane rigidbody using moment and arm. That would have no limitations of where I apply force. Would there be any negatives of using this second system?
     
  38. Oyedoyin1

    Oyedoyin1

    Joined:
    Oct 30, 2016
    Posts:
    915
    Yes, You can see the Trim settings under "Trim Configuration" for each surface

    You can apply your force to the whole wing as a whole (you can use a function in the library to calculate the aerodynamic centre of the whole wing and use that as your application point) but the default forces are applied for each subdivision at the section centre.

    If you want to change where your forces are applied for each subdivision, just replace the geometric centre vector with your desired vector point
     
  39. skiwee

    skiwee

    Joined:
    May 30, 2020
    Posts:
    32
    So the panels that I see in the inspector are the panels I can apply the forces on right? And those same panels are how I define how big the control surfaces is on the whole surface(such as ailerons on the wing)? And if so are there any more precise ways to define the size of the control surface?
     
  40. Oyedoyin1

    Oyedoyin1

    Joined:
    Oct 30, 2016
    Posts:
    915
    Yes, the panels are the subdivisions of the aerofoil


    To map your control surface, you just have to tell the aerofoil which panel is covered by the control and what percentage of the panel root and tip chord is occupied by that control.
     
  41. Antotabo

    Antotabo

    Joined:
    Apr 8, 2016
    Posts:
    2
    Wow ! That kit seems awesome ! I've been implementing airfoil as well but mine is nowhere near as polished as this ! Congrats !

    I tried your helicopter demos and couldn't help but notice that they seemed very stiff and had some strange behaviours, notably they tend to self level even at low speed. I'm not a pilot but I doubt that should realisticallly happen. Also you seem to be using (according to the animation at least) a rigid tilting disc, wich isn't exactly accurate in terms of physics.

    I've personnally implemented helicopter physics using a much more brute force approach, in wich the blades are litterraly simulated as individual rigidbodies with airfoils, its a rotating wing after all. It has proven to behave very realistically (IMO that is) and most flight dynamics specific to helicopter seems to have naturally emerged i.e. autorotation, dissymetry of lift, retrieiving blade stalls, Vmax etc... Take a look:



    Downside of course is that the physic simulation must run at high rate (around 200-250 Hz) to capture proper angular discretization. It wouldn't work for smaller rotors above 1000RPM like on a quadcopter or a RC helicopter i.e.

    You can play the webGL (not recommended, performance is abysmal....) or download the build on my tiny website.

    Cheers !

    Edit: Forgot to mention, the newer solver type : "temporal gauss seidel" is needed for this brute force approach, the older solver introduces huge ghost angular drag, even more so past roughly 200 RPM on rotors. Wich not only limited the main rotor RPM but also callel for an excessive amount of counter torque force needed at the tail rotor. It was also quite bad at handling large Force/Mass ratio.
     
    Last edited: Jan 10, 2021
    Oyedoyin1 likes this.
  42. Oyedoyin1

    Oyedoyin1

    Joined:
    Oct 30, 2016
    Posts:
    915
    I intentionally made the web demo setups stiffer than usual :D I know most people will be running the demo with keyboard controls and having a super sensitive helicopter with no stabilization can prove very difficult to control (especially for people unfamiliar with the real world controls)

    In the system, you can just lower the balance angle and swing factor variables to lower or remove the stabilization effect.

    To increase sensitivity, you just have to lower the inertia values on the core object


    I ran into that very same physics count rate issue for the first model that was using that "Per blade rigidbody" analysis method. I stopped working on it cus it felt like Unity physics was seriously fighting back on some of my methods.
    The second model was based on the dynamic analysis from here: https://arc.aiaa.org/doi/book/10.2514/4.862083 For this I had to use Numerics MathNet library to make the math work in Unity. That created some version limitation as that library only functions with dot net 4.0 and above (This will cut off users with anything lower than Unity 2018)

    What I eventually discovered was that as much as I wanted to apply the forces on each aerofoil (like the fixed-wing does), I don't necessarily have to. I can just perform force and moment analysis on each blade while considering its rotation and then sum them together to get a total force vector on the helicopter as a single system.
    The advantage of this logic was that I could use normal physics settings, Is easier to explain to use and I didn't have to make any compromise as before.
    But I have plans to give another crack while I'm updating the rotary system :)

    I have a new model in the works that is based on a non-linear 6 dof analysis method, but I have to get it to work properly in Simulink before translating it into C# for Unity. I have my own Math library now so I won't be limited by dot net compatibility.
     
  43. Antotabo

    Antotabo

    Joined:
    Apr 8, 2016
    Posts:
    2
    Thats quite a torough response, thanks !

    Take a quick look back up, in the edit section of my post, temporal gauss seidel solver might come quite handy if you didn,t tried it yet.

    Thats neat, I though about that, expecially for high speed rotors, there is a point where it becomes impossible with multibody blades. Also I guess if you want a lighweight system that can scale well in terms of performance and that is easily implementable as an asset your aproach is the way to go.

    Still, I love how I can see all the individual blade movement and them reacting to the environment. But I understand that is way more hardcore than needed for most purposes. Plus, to prove your point, a lot of people I showed to just didn't even realized how intricate the simulation was. They were like : Hey ! Thats an helicopter ! ... Real Sherlock Holmes.

    FIY, I'd be interested to try a build with more realistic control system tuning as you mentionned
    and proper 4 axis binding to controller.

    Its seems everything you've done is out of my league anyway. Good luck !
     
    Last edited: Jan 10, 2021
    Oyedoyin1 likes this.
  44. Oyedoyin1

    Oyedoyin1

    Joined:
    Oct 30, 2016
    Posts:
    915
  45. Oyedoyin1

    Oyedoyin1

    Joined:
    Oct 30, 2016
    Posts:
    915
  46. Oyedoyin1

    Oyedoyin1

    Joined:
    Oct 30, 2016
    Posts:
    915
    V3 System update is now available on the store!!!

     
  47. makoto_snkw

    makoto_snkw

    Joined:
    Aug 14, 2013
    Posts:
    340
    Does this system have AI for waypoint system or something like that?

    Usage purpose example:
    1. Make "enemy aircraft".
    2. Make cut scenes.
     
  48. Oyedoyin1

    Oyedoyin1

    Joined:
    Oct 30, 2016
    Posts:
    915
    Technically you can now...but you'll have to break down the commands. Currently, the autopilot system takes in Speed, Altitude and heading commands.

    So you have to break the waypoints into those specific inputs i.e If the aircraft should go to waypoint A, how much speed should it have and how much should it turn.

    I'm still working on the AI system to be refined enough to take straight Waypoint vectors
     
  49. Oyedoyin1

    Oyedoyin1

    Joined:
    Oct 30, 2016
    Posts:
    915
    Helicopter VR Controls

     
    xDeveloper and Bartolomeus755 like this.
  50. makoto_snkw

    makoto_snkw

    Joined:
    Aug 14, 2013
    Posts:
    340
    I think I can code the AI, but I prefer not to at the moment.
    My timeline is tight!
    So I guess I just use Unity Sample Asset for 2018 for now while waiting for yours.

    When you doing the AI system, don't forget to do the "enemy detection" as well.

    Thanks.
     
    Oyedoyin1 likes this.