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

[RELEASED] Simple Bicycle Physics

Discussion in 'Assets and Asset Store' started by AiKodex, Feb 2, 2022.

  1. AiKodex

    AiKodex

    Joined:
    Jan 21, 2021
    Posts:
    316
    Were you able to resolve the issue by tweaking the physics settings for the project?
    This discussion provides a few workarounds and also mentions solutions for 2021.2 (last post).



    Here is a solution provided @rz_0lento that may fix the issue you're facing.
     
  2. viroroi

    viroroi

    Joined:
    Dec 27, 2015
    Posts:
    4
    I would like to know if it is possible to simulate the change of gears of the bicycle with the existing parameters. For example, when you are climbing a mountain, you change gears to make less effort to climb it.
     
  3. AiKodex

    AiKodex

    Joined:
    Jan 21, 2021
    Posts:
    316
    Integrating a gear system should not be a problem. In fact, we just implemented the this feature for one of our upcoming products using a modified version of the Simple Bicycle Physics script.

    All you need in the bicycle controller are the parameters - Acceleration Curve, Torque and Top Speed. For the visual aspect, you can also change the value pedalSettings.pedalingSpeed according to the gear.
    A rough linear approximation of Gear Speed segments can be implemented in the following way:
    Current Gear = floor⌊(Current Speed + NumOfGears) / Top Speed⌋ Clamped to a range(0,NumOfGears)

    With the this current gear, you can modify torque, acceleration curve and pedaling speed accordingly.
    Although the range is 0,NumOfGears, the current gear will start from 1. 0 is usually kept as neutral. This is so that when you multiply Torque with a neutral gear, the result is 0 as there is essentially no net torque applied when the cycle/vehicle is in the neutral gear.

    If you want to implement neutrals with a delayed gear change, you can start a coroutine like so:

    Code (CSharp):
    1. IEnumerator GearChange(float time)
    2.         {
    3.             changeGear = false;
    4.             bicycleGearSettings.currentGear = 0;
    5.             yield return new WaitForSeconds(time);
    6.             changeGear = true;
    7.         }
    Where changeGear is a boolean that is a master control for changing gears
     
  4. viroroi

    viroroi

    Joined:
    Dec 27, 2015
    Posts:
    4
    Thanks for your quick response. With your support I have been able to find the parameter I was looking for (Torque), because in order to climb a more slope ramp, the cyclist is able to climb it with the same force.
    We can also obtain the value of the current gear with the formula you provided, and the effect of pedaling speed makes it more realistic.
     
    AiKodex likes this.
  5. PrimusThe3rd

    PrimusThe3rd

    Joined:
    Jul 3, 2017
    Posts:
    69
    Hello, will there be any electric (3wheel) scooter model in the future..similar as seen on attached screenshot? Regards, Primus
     

    Attached Files:

    Last edited: Jul 10, 2022
  6. AiKodex

    AiKodex

    Joined:
    Jan 21, 2021
    Posts:
    316
    Hello Primus,

    Simple Bicycle Physics (SBP) may not have an update specifically for electric 3-wheelers (from the attached screenshot) as they require a very different animation set and IKs. However, making these 3 wheel electric scooters without the rider should be possible using SBP.
     
    PrimusThe3rd likes this.
  7. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,476
    Just info, you can use standard unity wheel controller code to make something like that, like mine upload_2022-7-14_18-4-46.png
     
    AiKodex and PrimusThe3rd like this.
  8. BlackSnd

    BlackSnd

    Joined:
    Mar 7, 2020
    Posts:
    1
    Hi,
    We purchased this asset recently and it is a good investment.
    However I have been trying to reach you at info@aikodex.com for some clarification and you haven't responded yet.
    I am trying to connect a smart trainer (Wahoo kickr) and Blync with this bicycles. We have purchased the ant+ package from the asset store as well. I just need to use the speed from the trainer to move this bicycle and the turn data from blync to control the turning.
    Please help.
     
  9. AiKodex

    AiKodex

    Joined:
    Jan 21, 2021
    Posts:
    316
    Hello,

    Please confirm if you had received this email with the attachments:

     
  10. wilgieseler

    wilgieseler

    Joined:
    Oct 17, 2013
    Posts:
    84
    It definitely seems like BicycleController should have a pluggable input interface instead of copy-and-paste being required to change input settings (such as mobile controls, new input system, or being driven by AI).
     
    AiKodex likes this.
  11. AiKodex

    AiKodex

    Joined:
    Jan 21, 2021
    Posts:
    316
    By a pluggable Input Interface do you mean an additional script which handles input with public variables like acceleration control and steer control? If yes, this can be implemented in the next update. This idea seems like it will help users to modify the inputs themselves for trainers, controllers and other devices and make the asset independent of old/new input system issues.
     
    wilgieseler and iohouse like this.
  12. wilgieseler

    wilgieseler

    Joined:
    Oct 17, 2013
    Posts:
    84
    My thought was that you would have BicycleController look for another script on the same object that implements an interface like IBicycleControlScheme and that interface contains everything you would need (versus having public variables). That way there's no sharing of variables or anything, just a nice clean C# interface. Your existing controls could become LegacyInputBicycleControlScheme and MobileBicycleControlScheme or similar.

    Ideally also the control scheme can be swapped out via script at runtime (`bikeController.controlScheme = mobile`, etc).

    The same could done for the camera script. (Though since I am supporting both controller and mouse and keyboard and am using Cinemachine I will probably need to make my own anyway.)
     
  13. claudius_I

    claudius_I

    Joined:
    May 28, 2017
    Posts:
    251
    Hello.
    you will add Enter / Exit Mechanism in the new asset Simple Motocross Physics?

    Thank

    Claudio
     
    AiKodex likes this.
  14. AiKodex

    AiKodex

    Joined:
    Jan 21, 2021
    Posts:
    316
    claudius_I likes this.
  15. claudius_I

    claudius_I

    Joined:
    May 28, 2017
    Posts:
    251
    this is great :)

    I didn't notice the new thread, there isn't link included in the store.
     
  16. AiKodex

    AiKodex

    Joined:
    Jan 21, 2021
    Posts:
    316
    Ah yes, there was no way of knowing. We’ve added it now, hopefully it’ll be live within a working day or two.

    Please tell us how you like it if you plan to try out the asset.
     
  17. claudius_I

    claudius_I

    Joined:
    May 28, 2017
    Posts:
    251
    I will buy in 10 days :). I looking for a good motor system. I creating a game where the character can walk y drive vehicules. I think Motorcycle system is starting keed behind in comparison with other new asset. need a update also.
     
  18. herolg

    herolg

    Joined:
    Jul 7, 2022
    Posts:
    2
    Can I add my own custom bicycle?
     
    AiKodex likes this.
  19. AiKodex

    AiKodex

    Joined:
    Jan 21, 2021
    Posts:
    316
    Yes, that is very much possible. We'll be adding an extra page or two of documentation on how developers can add their own bicycle.
    In the meantime, if you want, we could send the basic guide we have (pre-release documentation) via email (info@aikodex.com)
     
    herolg likes this.
  20. herolg

    herolg

    Joined:
    Jul 7, 2022
    Posts:
    2
    Great! Could you email me the documentation?
    next.vr2022@gmail.com
     
  21. claudius_I

    claudius_I

    Joined:
    May 28, 2017
    Posts:
    251
    Hello, there is a method to know the velocity?
     
  22. AiKodex

    AiKodex

    Joined:
    Jan 21, 2021
    Posts:
    316
    Yes. This can be done through basic rigidbody functions.
    You can use something like this:

    Code (CSharp):
    1. bicycleController.rb.velocity.magnitude
    If you want to know the velocity of the bicycle with respect to its local forward movement, you can use:

    Code (CSharp):
    1. bicycleController.transform.InverseTransformDirection(bicycleController.rb.velocity).z
     
    Last edited: Sep 15, 2022
    claudius_I likes this.
  23. AiKodex

    AiKodex

    Joined:
    Jan 21, 2021
    Posts:
    316
    [UPDATED]
    v2.1
    - New Bicycle Added - Downhill Bike (Type : MTB)
    - New Trick Added - Wheelie
    - New Rider 3 clothing and helmet added
    - Procedural IK enhancements. More accurate movements of the cyclist in reaction to change in momentum.
     
  24. AiKodex

    AiKodex

    Joined:
    Jan 21, 2021
    Posts:
    316
  25. blackbird

    blackbird

    Joined:
    Aug 9, 2011
    Posts:
    591
    can you upload the project examples please
     
  26. AiKodex

    AiKodex

    Joined:
    Jan 21, 2021
    Posts:
    316
    The project samples contain assets that we may not have the permission to redistribute.
    We can send you the sources via email however. There are also some custom assets that we made, collected and assembled from different sources, modelers and artists.
     
    blackbird likes this.
  27. blackbird

    blackbird

    Joined:
    Aug 9, 2011
    Posts:
    591
    send me the list
     
  28. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,251
    This and the motorbike physics look superb, but without demos I can't tell how they actually feel. Do you not have any?
     
  29. AiKodex

    AiKodex

    Joined:
    Jan 21, 2021
    Posts:
    316
    Sure, please send us an email at info@aikodex.com so that we can hook you up with a demo of your liking.
     
  30. sisusisu

    sisusisu

    Joined:
    Nov 26, 2013
    Posts:
    14
    Was trying to make a bicycle simulator with this controller, only the riding part is taken care by this controller but are facing few issues.

    1) Since a sphere collider is used for the wheels, it jumps when it reaches near a wall or in a track having obstacles. At times it goes for an unending loop.

    2) Tried to integrate a game controller input but was in vein. Is there any solution for this.

    Awaiting a reply
     
  31. AiKodex

    AiKodex

    Joined:
    Jan 21, 2021
    Posts:
    316
    Hello,

    Yes the sphere collider issue we're aware of and are currently trying to develop a custom ellipsoid equation based collider. For now, you could try circumventing the issue by adjusting the colliders of the wall to be indented/offseted inside.

    The asset uses the legacy input system and a few direct key bindings from the script. You can configure your gamepad's controls with the Vertical axis and the Horizontal axis in the Project Settings. For the direct key bindings in the scripts, you can replace the code for your specific gamepad input. Here is a link that may help you find the correct bindings.
     
  32. AiKodex

    AiKodex

    Joined:
    Jan 21, 2021
    Posts:
    316
    [Updated]
    - New Character Model and a new livery for downhill bike
    - Foot IK Improvements

     
    Rowlan, blackbird and khos like this.
  33. MorpheusXI

    MorpheusXI

    Joined:
    Jan 18, 2018
    Posts:
    71
    Is there a plan/ETA to migrate to new input system. I only ask as I recently bought this and when importing to existing project and running MTBRider2Setup Scene I had conflict with another controller within project (I remember when importing the other Asset it updated to new input system, noting I subsequently imported SBP.

    1.
    InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings.
    SBPScripts.BicycleController.CustomInput (System.String name, System.Single& axis, System.Single sensitivity, System.Single gravity, System.Boolean isRaw) (at Assets/Simple Bicycle Physics/Scripts/BicycleController.cs:459)
    SBPScripts.BicycleController.ApplyCustomInput () (at Assets/Simple Bicycle Physics/Scripts/BicycleController.cs:406)
    SBPScripts.BicycleController.Update () (at Assets/Simple Bicycle Physics/Scripts/BicycleController.cs:372)

    2.
    InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings.
    SBPScripts.PerfectMouseLook.LateUpdate () (at Assets/Simple Bicycle Physics/Scripts/PerfectMouseLook.cs:35)
     
  34. blackbird

    blackbird

    Joined:
    Aug 9, 2011
    Posts:
    591
    please we need sound implementation :/
     
  35. Felicityinc

    Felicityinc

    Joined:
    Nov 24, 2016
    Posts:
    24
    Hey @Xpert3D , is there any updates on this feature for the SBP?
     
    blackbird likes this.
  36. AiKodex

    AiKodex

    Joined:
    Jan 21, 2021
    Posts:
    316
    Hello @Felicityinc, we are currently working on it. Hopefully, we will push out an update next week and update the forum once we do. We hope to have basic sounds working by then.
     
    blackbird and Felicityinc like this.
  37. AiKodex

    AiKodex

    Joined:
    Jan 21, 2021
    Posts:
    316
    [Updated]
    - Sounds added to the MTB scenes
    - Cycle riding audio/recording loops clips added
    - Bug fixes and improvements

     
  38. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    313
    Picked this up recently.. manual needs an update.. dislike the graphs would be nice if there were simpler way to make changes to values than using unity's awful graph editor or some explanation on the curves an values to stick too or ranges to stay within.

    Was trying to find a way to increase leaning/turning angle... to do tighter/back wheel skidding turns? that would be nice not seen a way to do it.

    I guess so far it seems alright, standing up to peddle faster?, I always thought the bicycle in Heroes and Generals was pretty solid.. not a super fast bike but the gameplay for it was pretty good, ie turn angle etc
     
    MorpheusXI likes this.
  39. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    313
    oh other question.. any future update on supporting networking ie with Unity official network framework or mirror/fishnet etc? for this asset and the other ones? I have a few of them now.
     
  40. John3D

    John3D

    Joined:
    Mar 7, 2014
    Posts:
    441
    Looks nice!
    I would like to buy it but where can I play an Android demo first, please?
     
  41. AiKodex

    AiKodex

    Joined:
    Jan 21, 2021
    Posts:
    316
    Please send us an email at info@aikodex.com. The demo can be then delivered via email.
     
  42. AiKodex

    AiKodex

    Joined:
    Jan 21, 2021
    Posts:
    316
    We will update the documentation with the range of values that works well with each variable.

    As for skidding of the rear wheel, you could reduce the R Wheel Friction setting to somewhere around 0.5 for both static and dynamic (Vector2: X and Y).

    The pedaling speed can be changed in the inspector / with an external script. You can find the parameter in the Pedal Adjustments class in the inspector.

    Thank you for the feedback!
     
  43. AiKodex

    AiKodex

    Joined:
    Jan 21, 2021
    Posts:
    316
    As of now there are no plans for updating the asset with a multiplayer networking code. However, we can look into developing a multiplayer add-on for Simple Bicycle Physics, perhaps as a separate asset.
     
    charlestango, John3D and Felicityinc like this.
  44. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    313
    well a multiplayer addon asset that also supports the other vehicle assets you have? would be good as all in one support.
     
    Felicityinc likes this.
  45. John3D

    John3D

    Joined:
    Mar 7, 2014
    Posts:
    441
    Hi @Xpert3D ,

    For the bicycles that have the Ragdoll setup, how do I make the rider to get back on the bike for Mobile, please?
    In the documentation I see that you press R key and this works for web version.
    I didn't managed to find the code with for the GetKeyUp. In what script is that code, please?

    "As soon as ‘R’ is pressed, the ragdoll is reset and the gameobject is destroyed. This happens in LateUpdate() and GetKeyUp respectively."

    Thanks!

    Kind Regards,
    John
     
  46. AiKodex

    AiKodex

    Joined:
    Jan 21, 2021
    Posts:
    316
    Hello John3D,

    The code for resetting the ragdoll can be found inside the CyclistAnimController.cs line:98. The code was later changed to the GetKeyDown method in the Update() function as the LateUpdate() took a frame and GetKeyUp made this delay more noticeable.
     
    John3D likes this.
  47. John3D

    John3D

    Joined:
    Mar 7, 2014
    Posts:
    441
    Many Thanks!!!

    I managed to make a ResetBiker function and attach that to a UI button.
    I think it would be useful to have this option in your scripts. Would you like to add it in the next update, please?
     
  48. AiKodex

    AiKodex

    Joined:
    Jan 21, 2021
    Posts:
    316
    We're glad you were able to make it work.
    Of course, we can include this as an update in the asset.
     
  49. Rastar

    Rastar

    Joined:
    Sep 14, 2012
    Posts:
    73
    Hi there,

    in one of your promotional videosthe asset is called "trainer ready" (referring to external smart trainers, I assume). I couldn't find any specific code in the scripts or instructions in the docs about this, could you give me a hint? Thanks!
     
  50. AiKodex

    AiKodex

    Joined:
    Jan 21, 2021
    Posts:
    316
    Hello Raster,

    The controls can be easily modified to suit your needs hence the term trainer ready. Steering angle, acceleration and pedalling adjustments are easy to change. However, we would like to clarify that the developer still needs to code in the Bluetooth or ANT+ connections. It is important to note that the asset does not ship with pre-existing scripts that make connections to Bluetooth devices.