Search Unity

How to adjust acceleration based parameters?

Discussion in 'Physics' started by grzesiekfuta, Oct 16, 2020.

  1. grzesiekfuta

    grzesiekfuta

    Joined:
    Jan 3, 2020
    Posts:
    3
    I'm making racing game and I want to implement car acceleration time, it is acceleration time 0-100 kmh
    how to implement it?
    for example if I have in my json data property
    "acceleration": 3

    which means 3 seconds, so what parameters I must adjust?
    Generally I mean to use physics, I'm using standard assets car prefab based custom model



    And see 2 possible ways:
    • to experiment with parameters
    • or map the acceleration time from json data with some method
     
    Last edited: Oct 16, 2020
  2. grzesiekfuta

    grzesiekfuta

    Joined:
    Jan 3, 2020
    Posts:
    3
    ok so I apply the same force but
    for one car add smaller mass so then it accelerates faster
    and for second car add higher mass so then accelerates slower
    I think this is the temp solution
     
    Last edited: Oct 28, 2020
  3. tjmaul

    tjmaul

    Joined:
    Aug 29, 2018
    Posts:
    467
    The AddForce method comes with an optional parameter “forceMode” that you can set to ForceMode.Acceleration. This makes acceleration independent of the rigidbodies mass. The mapping you need for 0-100km/h to seconds is:

    acceleration = maxSpeed_kmh / 3.6f / seconds0to100
     
    grzesiekfuta likes this.
  4. grzesiekfuta

    grzesiekfuta

    Joined:
    Jan 3, 2020
    Posts:
    3
    yes, thanks!