Search Unity

FGear Vehicle Physics (v1.12 Released)

Discussion in 'Assets and Asset Store' started by tasadar, Dec 18, 2018.

  1. tasadar

    tasadar

    Joined:
    Nov 23, 2010
    Posts:
    290
    fgearS.png
    Introducing F-Gear Vehicle Physics
    FGear is a custom vehicle physics solution for unity that helps you build arcade or semi-arcade style racing games. The package consists of a core module and some extra features that were used for making the demo scenes. It is mostly focused on 4 wheel cars but multi axle setups are also possible.

    Asset Store : http://u3d.as/1pAg


    Warning : Some of the content in these demos are not included in the package!



    Available Demos:

    *Controls for Pc Demos: Arrow keys + Space for handbrake + R for reset + B for lookback.

    Documentation: Available here

    Core features:
    • Desktop or mobile.
    • Single script component for a driveable vehicle.
    • Full source code.
    • Adjustable integration steps.
    • Simplified pacejka, pacejka96 and MF6.1 tire model options.
    • 3D wheel support(multiple raycasts or sphere/convex cast).
    • Simple engine model with a torque curve.
    • Configurable auto/sequential/manual(h-pattern) transmissions.
    • Open, locked or lsd differentials.
    • Ackerman steering, toe and camber.
    • Adjustable torque and brake distribution of axles.
    • Simple spring/damper suspensions with preload option.
    • AeroDynamics component for drag and downforce effects.
    • Standard input manager with keyboard,joystick and wheel+shifter support.
    • Driving aids like abs, asr, esp and anti roll bars.
    • Detailed telemetry ui.
    • Basic save/load system for fast prototyping.
    • Various sample setups and demos.
    Extras:
    • 3rd person camera script.
    • Basic AI driver.
    • Sample visual&sound effects like engine, skid and muzzle effects.
    • Forcefeedback script using logitech gaming sdk.
    • Joystick vibration sample script with XInput.
    • Minimap and gauge UI samples.
    • Mobile input demo.
    • Bezier spline tool.
    • Runtime vehicle creation/modification demo.
    • Arcade style driving assists script.
    • BikeHelper script for fake motorcycle setups.
    • Multiplayer sample with Pun2.
    • Rewind and replay sample.

    Some Screens:


    s2.jpg s4.jpg s6.jpg s8.jpg

    ---------------------------------------------------------------------------------------------------------------------
    Check the 0-OverView.pdf file in Documentation folder for the change log and detailed notes.
    ---------------------------------------------------------------------------------------------------------------------
    Please share your thoughts, suggestions, any feedback is welcome.
     
    Last edited: Jan 9, 2024
    Ian094 and Flurgle like this.
  2. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,761
    Looks interesting, tried the Touring car demo and drift demo with an Xbox controller and they both turn right with no steering, joystick works fine on other driving games in Unity.
     
  3. tasadar

    tasadar

    Joined:
    Nov 23, 2010
    Posts:
    290
    interesting, i also have a xbox controller and it works fine, i assume it works ok with keyboard.
    hmm how many controllers are connected to your system, may be another controller is interfering?
    and which xbox controller do you have, is it wireless/cabled, xbox360 or xboxOne, thank you.
     
    Last edited: Dec 18, 2018
  4. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,761
    Just one controller, as I say works fine with all other Unity vehicle systems and games. I think it needs a bigger dead zone as the little black steering mark is clearly offset to the right showing steering input.
     
    Last edited: Dec 18, 2018
  5. tasadar

    tasadar

    Joined:
    Nov 23, 2010
    Posts:
    290
    @SpookyCat thanks for the help.

    it seems that some xbox controllers axis values are not always zero even if you do not touch them.
    FGear uses Input.GetAxisRaw method and you can configure sensivity/deadzones etc. for each vehicle but i will add an option to just use Input.GetAxis method.

    i increased the controller dead zones and reuploaded the pc demos.
     
  6. tasadar

    tasadar

    Joined:
    Nov 23, 2010
    Posts:
    290
    before the release i added a save/load mechanism for fast prototyping.
    simply the component properties are dumped to a json file and read back when needed.
    i also made a quickstart tutorial video:

     
  7. tasadar

    tasadar

    Joined:
    Nov 23, 2010
    Posts:
    290
  8. MathewHI

    MathewHI

    Joined:
    Mar 29, 2016
    Posts:
    501
    I’m working on a F1 style game, the example is really great and I like how the tires spin out in low gears. I don’t know a ton about engines but I’m assuming that’s because there’s more power being supplied to the wheels on low gear. In high gears it doesn’t spin out too much, if I wanted to make it a little more challenging and have the potential to spin out when exiting corners with too much throttle, what would I need to do?
     
  9. tasadar

    tasadar

    Joined:
    Nov 23, 2010
    Posts:
    290
    this might be tricky to achieve here are some ideas:

    -your vehicle should have enough torque at wheels to loose longitudinal grip(high slip ratio) even in second and third gears. so higher engine torque and lower gear ratios are needed.
    -engine should be more aggressive with lower inertia.
    -tire forces generated by the pacejka96 formula(lateral and longitudinal) are not just summed up but they are combined so that wheels loose lateral grip when longitudinal slip occurs so you need to tweak the combined force parameters of your tire model. this part will be hard to make right since those parameters have no real physical meaning but you can see the resulting curves and you can find basic explanation of the tire parameters in the documentation.

    Untitled.jpg

    so i recommend you to create a new tire model, try to understand how those resulting curves effect tire friction and start experimenting.

    good luck.
     
  10. MathewHI

    MathewHI

    Joined:
    Mar 29, 2016
    Posts:
    501
    Thanks for the info, I still need to learn a lot, I’ll give it a shot
     
  11. MathewHI

    MathewHI

    Joined:
    Mar 29, 2016
    Posts:
    501
    How do I set variables during runtime? I tried this as a test but its not working.
    Code (CSharp):
    1.  WheelOptions wheelOptions;
    2.  
    3.     // Use this for initialization
    4.     void Start ()
    5.     {
    6.         wheelOptions = new WheelOptions();
    7.        
    8.        
    9.  
    10.     }
    11.    
    12.     // Update is called once per frame
    13.     void Update ()
    14.     {
    15.         wheelOptions.setLateralFriction(1f);
    16.     }
     
  12. tasadar

    tasadar

    Joined:
    Nov 23, 2010
    Posts:
    290
    please check RuntimeSample.cs
    you need to have an existing vehicle say mVehicle then you can set like:

    Code (CSharp):
    1. mVehicle.getAxle(0).getWheelOptions().setLateralFriction(1.0f);
    2. mVehicle.getAxle(0).applyWheelOptions();
     
  13. MathewHI

    MathewHI

    Joined:
    Mar 29, 2016
    Posts:
    501
    I've got using FGear at the top as well
     
  14. MathewHI

    MathewHI

    Joined:
    Mar 29, 2016
    Posts:
    501
    Thanks I appreciate it.
     
  15. MathewHI

    MathewHI

    Joined:
    Mar 29, 2016
    Posts:
    501
    I would like to try and get a little more sharper steering. From my understanding of the documentation I would change that with the Steering Sensitivity Curve. If I just click on the box without changing anything it automatically changes my steering to where the back wheels lock up and prevent lateral movement.
     
  16. tasadar

    tasadar

    Joined:
    Nov 23, 2010
    Posts:
    290
    you mean the property field for the curve? if you click on it it will open the curve editor.

    sorry i didnt understand this, a short video would be helpfull to understand the problem.
     
  17. MathewHI

    MathewHI

    Joined:
    Mar 29, 2016
    Posts:
    501
    Here is Formula Sample with default settings


    Opening Steering Sensitivity Curve without making changes causes back wheels to brake when turning
     
  18. tasadar

    tasadar

    Joined:
    Nov 23, 2010
    Posts:
    290
    it has nothing to do with that curve, it seems that when you steer the car also handbrakes. it is not visible in the video but your axis settings are probably not proper. if you create a new project you need to setup axis inputs from unitys input manager(edit->project settings->input) or copy/paste the sample settings file that i mentioned a couple of times in the documentation : https://www.dropbox.com/s/h69d08r1lbf460i/InputManager.asset?dl=0

    ins.jpg
     
    Last edited: Apr 3, 2019
  19. MathewHI

    MathewHI

    Joined:
    Mar 29, 2016
    Posts:
    501
    I see, I would never have thought to do that because the controls worked right out of the box plus I never made any changes. Thanks for the help.
     
  20. tasadar

    tasadar

    Joined:
    Nov 23, 2010
    Posts:
    290
    no problem.

    normally you may not get any problems because the default values in fgear are same as the default axis values in unity but if the vehicle prefab contains a different axis input like "Handbrake" and if that axis is not present in inputmanager then the system assigns the first available axis which is "Horizontal" and then your vehicle handbrakes when you steer :)
     
    MathewHI likes this.
  21. MathewHI

    MathewHI

    Joined:
    Mar 29, 2016
    Posts:
    501
    Sorry if this is another simple question but where are the brakes? Is the hand brake and foot pedal brakes one in the same? I saw in the docs it says you need a combined axis for throttle and brakes, I'm not exactly sure what that means.
    I'm using an Xbox One controller and I have "Throttle" mapped to right trigger and "Hand brake" mapped to left trigger but is there a "Floor pedal brake" I can map to the left trigger?
     
  22. tasadar

    tasadar

    Joined:
    Nov 23, 2010
    Posts:
    290
    vertical axis is for throttle/brake. for ex. up for throttle and down for brakes.
    handbrake has its own axis as you can see in the image above.

    i have also tested the demos with an xbox 360 controller and if you use the settings file i mentioned before the right axis will be throttle and the left axis will be brakes which is common for racing games.

    if you want to use the left trigger for handbrake and another button for regular brakes i am afraid you cant do it without modifying the code at the moment. you need to separate vertical axis into throttle&brake axis and then you can assign different axis to them. xbox controller provides both combined and separate axis values for left and right triggers. more info here : http://wiki.unity3d.com/index.php/Xbox360Controller
     
  23. MathewHI

    MathewHI

    Joined:
    Mar 29, 2016
    Posts:
    501
    I didn't know how to open an .asset file but I figured it now, I see what you mean by combined axes. So I put throttle/brake on joystick 3rd axis and invert and it works like expected thanks.
     
  24. tasadar

    tasadar

    Joined:
    Nov 23, 2010
    Posts:
    290
    .asset is a binary file you cant read it, you just need to replace your own InputManager.asset in the ProjectSettings folder to use the same axis setup. keep it up.
     
  25. Lesnikus5

    Lesnikus5

    Joined:
    May 20, 2016
    Posts:
    131
    I'm looking for a realistic car controller. The presence of pacejka96 tire model, AeroDynamics component and basic forcefeedback delight me. FGear done with the expectation of realism?

    Physics seemed to me quite interesting. I like the way cars are driven. But there are a couple of questions.

    In a Pc Drift Demo, it seemed to me that at the moment when two wheels on one side of the car are on the grass (poor grip), and the other two wheels on the other side of the car are on the asphalt (good grip), when braking, the car turns in towards better grip, towards asphalt. And in the Sandbox Demo of this is not observed at all. Why? Or maybe I was wrong? And there is no such function at all, because the car turns around because of the unevenness of the landscape, and not because of the super-detailed physics of tire friction?

    I mean braking the handbrake when accelerating in a straight line in this position of the car:

    2.jpg

    Also in the Sandbox Demo there is no loss of controllability of the car and its avoidance to the side when braking with a handbrake after acceleration in a straight line, although there is definitely this feature in the Pc Drift Demo. Are any realism features disabled in sandbox demo?

    You also promised a 3D wheel support of multiple raycasts. But in the demos I did not find it. Why?

    1.jpg

    Thank you in advance for the answers! Your project looks very interesting!
     
  26. tasadar

    tasadar

    Joined:
    Nov 23, 2010
    Posts:
    290
    hi, thanks for your interest, i will try to give my honest answers :)

    -Pacejka96 is under the hood if you have a good set of parameters if not be warned that tuning these parameters is painful, nearly 50 parameters for the tire model!
    -Aerodynamics component is very simple, consists of wind drag & down force.
    -Forcefeedback is on my todo list, currently what you get is only a call to the logitech sdk that gives a small torque that aligns your steering wheel to the default orientation.

    the difference is just about the vehicle/tire setup. in drift demo there is a different tire model setup but i tried to do it with the tire model used in sandbox demo as well and that behavior also occurs if you tweak a bit. i need to say that adjusting tire grip based on the hit surface is not part of the core module, there is a sample implementation that is based on the physic material but you can also make your own.

    its not about enabling/disabling something, its just about the setup.

    3d wheel support is available but i forgot to enable it on some vehicles in the demo, the tractor and the 8x8 are good candidates. This feature is a bit performance heavy though if you increase the number of raycasts and mostly has no effect if you drive on flat surfaces.
     
    Lesnikus5 likes this.
  27. MathewHI

    MathewHI

    Joined:
    Mar 29, 2016
    Posts:
    501
    Here is another loaded question but what is the reason/reasons that make the car slow down while turning? I'm assuming its a multitude of factors and I like the simulation aspect but I might want to tone it down just a bit
    and not make the car loose that much speed while turning.
     
  28. tasadar

    tasadar

    Joined:
    Nov 23, 2010
    Posts:
    290
    if you switch to neutral gear, set rigidbody drag and aerodynamics drag coefficients to zero and set wheels internal friction to zero then there is no force left to slow down the vehicle. in such case if you steer then the below image is your answer. its inevitable, if you decrease lateral friction then you understeer all the time.

    car.jpg
     
    MathewHI likes this.
  29. Lesnikus5

    Lesnikus5

    Joined:
    May 20, 2016
    Posts:
    131
    Sounds like something really cool. I'm not afraid of tons of settings :)

    Many assets, called "realistic", do not even have a simple model of aerodynamic drag. Your asset is called semi-arcade and it has it. Moreover, there is a need to maintain a balance between productivity and the depth of realism. So simplicity is not always bad.

    The fact is that I still was not sure that I had not dreamed it. I drove a few days in the demo. I found a very slippery piece of dirt in the Sandbox Demo, and was able to do some tests. My previous impressions were not wrong, the car really turns in the right direction, if the force of adhesion to the surface for the right and left pair of wheels differ! It's really cool!

    It’s a pity that the introduction of cars into my game is still very far away (there are a lot of other things to be done before this), otherwise I would immediately buy F-Gear right now. But I do not buy in advance. I have to wait a while, but your asset looks the most interesting of all. Believe me, I studied almost all the vehicle assets in the store.

    Although there is still something to improve. For example, when the car is standing still for some reason (for example, the car has rested against the wall), and the wheels spin and rub against the surface, the smoke from the wheels does not go.

    Can you fix it?

    However, this is more of a minor niggle than a big problem. I am delighted with the detailed tire model. I saw something similar in the magnificent UniCar, but it is no longer sold and it is impossible to buy it now.. There are a couple of assets with "simulator" car controller, but they have closed source code (MoDyEn, Edy's Vehicle Physics Pro). For me, closed source code is a very big disadvantage. So F-Gear is really on my list :)
     
    Last edited: Apr 22, 2019
  30. tasadar

    tasadar

    Joined:
    Nov 23, 2010
    Posts:
    290
    thanks for your comments, glad you like it.

    if you check the asset store page of fgear, some guy gave 2 stars because the AI is problematic but this is not an AI package :). visual effects, AI, sounds etc. all of these are demonstrative implementations, they are not actually part of the vehicle physics solution but to be used in showcase demos. that smoke thing is basically triggered by an if case like (A > B), you can change it the way you need in your game.
     
  31. Lesnikus5

    Lesnikus5

    Joined:
    May 20, 2016
    Posts:
    131
    Ok, I understand.

    I saw this review. Do not be discouraged by not fair assessment. I think that F-Gear has good potential to become popular if you continue to develop it.
    Should we expect updates? Are you planning to develop asset in the future? In which direction?

    There are some concern. How does the suspension behave if you load a car with a couple of 100 kilogram cubes? I met some car assets (it seems it was the Randomation Vehicle Physics), in which it was not possible to load cars with cargo, because rigidbody weighing even a 100 kilogram, that was placed on top of the car made tremble. Suspension did not behave adequately. What is the situation in F-Gear? Did you test it?

    I need the opportunity to put the load in the car.
     
    Last edited: Apr 23, 2019
  32. tasadar

    tasadar

    Joined:
    Nov 23, 2010
    Posts:
    290
    first of all i will fix any bugs/glitches found in the core module. adding new features(besides the planned ones) depends on interest. i already have some ideas about improvements but my focus will be about stability instead of pushing new features. an advanced suspension system may have little effect on the final result so its a bit about experimenting, if something makes dramatic changes it will possibly be added. as a side note i have ported the library to unreal engine and a friend of mine is using it for a game project.

    the tractor in the sandbox demo is already loaded, that trailer is 500kg, watch the suspension ui to the bottom right.

    and here is a gif showing 3 x 100 kg. boxes on the pickup: https://www.dropbox.com/s/88x0h9nagikay01/2019-04-23_15-45-49.gif?dl=0
     
    Last edited: Apr 23, 2019
    Lesnikus5 likes this.
  33. Lesnikus5

    Lesnikus5

    Joined:
    May 20, 2016
    Posts:
    131
  34. MathewHI

    MathewHI

    Joined:
    Mar 29, 2016
    Posts:
    501
    How would I go about getting access to the vehicle and placing it upright when it rolls over and gets stuck upside down?
     
  35. tasadar

    tasadar

    Joined:
    Nov 23, 2010
    Posts:
    290
    first of all you can call Vehicle.reset(position, rotation) for an instant reset.

    if you want to do it by applying forces and torques, call Vehicle.getBody() to get the Rigidbody and calculate necessary force/torque to apply. how to calculate them is another story, you can check here : http://digitalopus.ca/site/pd-controllers/
     
    MathewHI likes this.
  36. tasadar

    tasadar

    Joined:
    Nov 23, 2010
    Posts:
    290
    v1.1 changes
    -two more vehicle models added
    -save/load option for tire models
    -joystick vibration sample with XInput
    -new arcade style recovery assists (check easydrive scene)
    -improved sample scenes
    -minor bug fixes
     
    Last edited: May 28, 2019
  37. CoderPro

    CoderPro

    Joined:
    Feb 21, 2014
    Posts:
    327
    Hi,
    I want to try this. Could you build a mobile demo for this ? Is this for drift assist ?
    Thanks
     
  38. tasadar

    tasadar

    Joined:
    Nov 23, 2010
    Posts:
    290
    hi, i can do that but there is a faster way :)

    check this one : https://forum.unity.com/threads/android-game-long-rider.676069/

    this does not actually use fgear(started this one before developing fgear) but uses the same arcade recovery assists. arcade assists script contains 4 types of assists and two of them can be useful for drifting.
     
    Last edited: May 31, 2019
  39. CoderPro

    CoderPro

    Joined:
    Feb 21, 2014
    Posts:
    327
    Hi,
    Thanks for suggestion.

    But i want to using your physics to make drift game for mobile using tilt control. And i need make car easy to drift like arcade drift. I hope you will make a demo for this.

    Thanks in advance
     
  40. tasadar

    tasadar

    Joined:
    Nov 23, 2010
    Posts:
    290
    have you checked the Android Drift Demo, there is a link to the apk in the first post.
    it is based on v1.0 and not very easy to drive(subjectively) but could be easily improved.
     
  41. CoderPro

    CoderPro

    Joined:
    Feb 21, 2014
    Posts:
    327
    Yes, i was tested this demo, but it quite difficult to drift. And i want to see that your car physics can drift smoothly and easy in mobile (using tilt control or arrow button).
    Could you improve drift behaviour and make new demo for that?
    Thank in advance !
     
  42. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    1,148
    Hi @tasadar,

    is there a way to increase longitudinal grip only for faster acceleration !?

    Thanks !
     
  43. tasadar

    tasadar

    Joined:
    Nov 23, 2010
    Posts:
    290
    only for faster acceleration?

    if your vehicle looses traction while accelerating you can increase longitudinal grip by altering tire model or just increase the longitudinal friction coefficient in wheel settings but this also effects braking not just acceleration.
     
  44. tasadar

    tasadar

    Joined:
    Nov 23, 2010
    Posts:
    290
    can not promise but i will look into it.
    currently working on a more realistic differential implementation after then i will reiterate all demos.
     
  45. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    1,148
    I am referring to case when you pull the hand brake and make 180 turn, after that i would want to be able to get faster acceleration instead of spinning the wheels !
     
  46. tasadar

    tasadar

    Joined:
    Nov 23, 2010
    Posts:
    290
    ok, you can do it by a couple of ways.

    -first i suggest you uncheck "Allow Wheel Rotation Against Engine" option(in wheel options), this way wheels will not rotate backwards after a 180 turn.

    -you can try ASR assist which eliminates spins.

    -you can alter tire model, tire model has many parameters and those parameters have no physical meaning, you can get the same result by changing different options. for ex. try setting PDX1 to '2' and you get less spins, set PDX1 to '1' and you get more spins.

    -you can increase longitudinal friction coefficient in wheel settings. this is actually a coefficient for final tire force, you can get faster acceleration with the same spin rate.

    -finally you can try traction assist in ArcadeAssists, this is unrealistic but could work for a specific use case.
     
  47. tasadar

    tasadar

    Joined:
    Nov 23, 2010
    Posts:
    290
    just found a UI bug which results wrong curve previews for newly created tire models(prefabs work fine). new tire models work fine in play mode but the editor UI shows incorrect curve data.

    it is very easy to fix and will be fixed in the next release.
    for the time being you can fix it by adding below function anywhere in Tire.cs

    Code (CSharp):
    1.  
    2. void Reset()
    3. {
    4.      init();
    5. }
    6.  
     
  48. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    1,148
    Hi, thanks for suggestions about better acceleration !
    Btw, if i change a value in the tire object prefab in scene and want to undo the change it does not work.
    Can you check that as well please !?
     
  49. tasadar

    tasadar

    Joined:
    Nov 23, 2010
    Posts:
    290
    are you sure? just checked it, changed values of tire model and ctrl+z takes the values back.

    edit : Reference Load and Reference Camber fails to undo, these will be fixed if possible. If you find any other values that fail, please inform.
     
  50. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    1,148
    Yep, this is what i am referring to :)