Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

[RELEASED] Simple Bicycle Physics

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

  1. Xpert3D

    Xpert3D

    Joined:
    Jan 21, 2021
    Posts:
    87
    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. Xpert3D

    Xpert3D

    Joined:
    Jan 21, 2021
    Posts:
    87
    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.
     
    Xpert3D 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. Xpert3D

    Xpert3D

    Joined:
    Jan 21, 2021
    Posts:
    87
    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,314
    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
     
    Xpert3D 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. Xpert3D

    Xpert3D

    Joined:
    Jan 21, 2021
    Posts:
    87
    Hello,

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

     
  10. wilgieseler

    wilgieseler

    Joined:
    Oct 17, 2013
    Posts:
    59
    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).
     
    Xpert3D likes this.
  11. Xpert3D

    Xpert3D

    Joined:
    Jan 21, 2021
    Posts:
    87
    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:
    59
    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:
    231
    Hello.
    you will add Enter / Exit Mechanism in the new asset Simple Motocross Physics?

    Thank

    Claudio
     
    Xpert3D likes this.
  14. Xpert3D

    Xpert3D

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

    claudius_I

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

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

    Xpert3D

    Joined:
    Jan 21, 2021
    Posts:
    87
    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:
    231
    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?
     
    Xpert3D likes this.
  19. Xpert3D

    Xpert3D

    Joined:
    Jan 21, 2021
    Posts:
    87
    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:
    231
    Hello, there is a method to know the velocity?
     
  22. Xpert3D

    Xpert3D

    Joined:
    Jan 21, 2021
    Posts:
    87
    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. Xpert3D

    Xpert3D

    Joined:
    Jan 21, 2021
    Posts:
    87
    [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. Xpert3D

    Xpert3D

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

    blackbird

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

    Xpert3D

    Joined:
    Jan 21, 2021
    Posts:
    87
    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:
    557
    send me the list
     
  28. andyz

    andyz

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

    Xpert3D

    Joined:
    Jan 21, 2021
    Posts:
    87
    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. Xpert3D

    Xpert3D

    Joined:
    Jan 21, 2021
    Posts:
    87
    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. Xpert3D

    Xpert3D

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

     
    blackbird and khos like this.
  33. MorpheusXI

    MorpheusXI

    Joined:
    Jan 18, 2018
    Posts:
    66
    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:
    557
    please we need sound implementation :/