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.
  2. Dismiss Notice

Motorcycle stabilization

Discussion in 'Scripting' started by maxwelldoggums, Mar 7, 2009.

  1. bcman

    bcman

    Joined:
    Feb 9, 2013
    Posts:
    139
    Wow.
    the7347, your bike looking very stabilized. How did u achieve that ?
     
  2. LS16BMX

    LS16BMX

    Joined:
    Nov 11, 2011
    Posts:
    94
    interesting, are you using mainly animations for your rider and bike etc ?
     
  3. pixelsteam

    pixelsteam

    Joined:
    May 1, 2009
    Posts:
    924
    Great work, very interested to follow your development!!!

     
  4. the7347

    the7347

    Joined:
    Dec 29, 2012
    Posts:
    33
    Hi...
    @bcman
    Basically I've done this combining the change of the drag and angular drag the rigidbody according is the inclination of the bike to the ground and if it is touching the ground. The method shown in this topic:
    http://forum.unity3d.com/threads/18807-Motorcycle-stabilization/page2
    Not is the best way to do it, but it works in an acceptable.
    How does to lift the bike on one wheel?
    I've tried changing the center of mass to a position that makes you lean, but spoils the stability. for that reason i use animation to get this.

    @pixelsteam
    thanks, the project is not about race, but will have all types of vehicles.Then publishes a post about this, when more advanced.

    @LS16BMX
    single use animations for the character, for motorcycle use some physical.
    I want to know which method you used to make the character of your bike has a sort of ragdoll, if possible ?
     
    Last edited: Jun 30, 2013
  5. bcman

    bcman

    Joined:
    Feb 9, 2013
    Posts:
    139
    oh, thank you.

    How did you beat the problem of sliding rear tire ?
    When I've try that mathod my rear wheel is always "roaming" on the road.

    The good point of this method is coping of gyroscopic effect as in real life.
    The bad point is sliding wheels when brute compensation
    BIKE.rotation = Quaternion.Slerp( BIKE.rotation, Quaternion.Euler( 0, BIKE.rotation.eulerAngles.y, 0 ), Time.deltaTime * 5 );
    began to rotate the bike.
    It's great idea and really good way to stabilize that but it's good for helicopter not bike, because bike is not hanged at air, it stands on the wheels.
     
  6. bcman

    bcman

    Joined:
    Feb 9, 2013
    Posts:
    139
    oh, about "wheelie" - the lifting bike.
    I've done nothing :) It happens by physics.
    Momentum "from" back wheel do it, no any code.
    Just weight of bike(200kg) and HP(~100hp) to back wheel :)
    Size of bike is as real bike ~2.4m
     
  7. the7347

    the7347

    Joined:
    Dec 29, 2012
    Posts:
    33
    The truth is that I'm not trying to make the bike physical realistic. rather something like Burnout Paradise bikes http://www.youtube.com/watch?v=lER9zByJrwk and for that reason did not investigate about real physics (unless necessary).
    My bike is very simple, the only thing I do is rotate the wheelcollider and play with the angular drag. The weight of the bike I've put 1600 kg, is too but this has helped with stabilization to bend, jump and crash. reacts very well to several cases considering not finished.
    I've also reduced the spring and damper at minimum. This also helps cornering. but I have no idea of physics real.

    To the problem of rear wheel slip, stiffness = 1 of the two wheels, and reduce it when this braking with the parking brake to create skid, but only at rear wheel, this works for me.

    Ahun so not a bad idea simulate real physical.

    Please continue your progress with the bike hereinafter ... :)
     
    Last edited: Jul 2, 2013
  8. pixelsteam

    pixelsteam

    Joined:
    May 1, 2009
    Posts:
    924
    Would be great if you sold it as an asset, as I would like to use the bike to drive on my own track.

     
  9. the7347

    the7347

    Joined:
    Dec 29, 2012
    Posts:
    33
    @pixelsteam
    Maybe, but it is very simple anyone could do it, is just test ... :)
    Is so simple that could post the script, but when I finish ... :twisted: :cool:
     
  10. LS16BMX

    LS16BMX

    Joined:
    Nov 11, 2011
    Posts:
    94
    Angular drag is very useful indeed, I wanted to find a way to code angular drag but just across the lean axis, I 'n not good with coding so i've not figured out if its possible yet ?
    I'm going to try some physics driven simulations using mecanim on the rider and the bike as it is, wish me luck haha it could be a long ride.
     
  11. bcman

    bcman

    Joined:
    Feb 9, 2013
    Posts:
    139
    "To the problem of rear wheel slip, stiffness = 1 of the two wheels, and reduce it when this braking with the parking brake to create skid, but only at rear wheel, I work so my"
    is it a problem ?
    just make "wheel.sidewaysFriction.stiffness = 0.02". Any numbers(honestly, it should be exponential or some kind of curve) you want.
    0.02 is just an instance, it's like full lose of friction.
     
  12. the7347

    the7347

    Joined:
    Dec 29, 2012
    Posts:
    33
    First, sorry for my bad English ... I'm using google translator :)

    my I work in this way:
    The side stiffness inversely proportional to the speed (if brake)
    Example: (METATEXT)
    if CurSpeed​​> 100 isBrake >> side stiffness = 0.02
    else if CurSpeed ​​<100 isBrake >> side stiffness = 0.5
    Is just an example, it is better with a formula
     
  13. xhudaman

    xhudaman

    Joined:
    Mar 25, 2013
    Posts:
    1
    i am working on a motorcycle game now and i was wondering if u would be willing to post code for the tilt? as that is the only thing im currently having trouble on and it would be really helpful to have
     
  14. the7347

    the7347

    Joined:
    Dec 29, 2012
    Posts:
    33
    If you mean this as this in this topic.
     
    Last edited: Jul 24, 2013
  15. pixelsteam

    pixelsteam

    Joined:
    May 1, 2009
    Posts:
    924
    Wanting to check in to see how it is going...

     
  16. the7347

    the7347

    Joined:
    Dec 29, 2012
    Posts:
    33
    Give me your email.
     
    Last edited: Sep 1, 2013
  17. bcman

    bcman

    Joined:
    Feb 9, 2013
    Posts:
    139
    Here is playable version of "real round tyre".
    Bike is unstable but damnit, it's only two whells and 200kg. It's hard to keep balance :)
    http://unitybike.ucoz.com/
     
  18. the7347

    the7347

    Joined:
    Dec 29, 2012
    Posts:
    33
    I like the look of your bike...
    seems a problem center of mass, your bike falls much, but is very simple solve this.

    A few months ago in the video post the download link of the initial basic project. Maybe I can help.
    I solved the stabilization currently pretty well, then I will put a video demonstration.

    If you need help contact me, the7347@hotmail.com
     
  19. bcman

    bcman

    Joined:
    Feb 9, 2013
    Posts:
    139
    Last edited: Apr 3, 2015
  20. bcman

    bcman

    Joined:
    Feb 9, 2013
    Posts:
    139
    Now playing with Unity5 new physics 3.3 wheelCollider.

    I disappointed with results: the real masses don't work now.
    The wheel works well if mass of 150kg
    The looking good suspension launch bike to air everytime if mass of bike less than 400kg(800kg is prefered)
    And so on.
    But there is result for Unity5


    Available WebDemo
    and at AssetStore
     
    Last edited: Jan 11, 2016
  21. bcman

    bcman

    Joined:
    Feb 9, 2013
    Posts:
    139
    Last edited: Jan 11, 2016
  22. anirudha

    anirudha

    Joined:
    Nov 11, 2014
    Posts:
    1
    Hey buddy I am bike passionist too..presently riding Yamaha FZ-S(150 only)...your bikes are sexy
     
  23. richardgengle

    richardgengle

    Joined:
    Jul 9, 2020
    Posts:
    9
    do you have a new link... your link is broke