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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

realistic rolling ball (Advanced Solution Needed)..

Discussion in 'Physics' started by EliJNemer, May 2, 2020.

  1. EliJNemer

    EliJNemer

    Joined:
    Aug 3, 2019
    Posts:
    123
    hello,

    is there a way to get realistic ball rolling, with respect to rolling friction and such. so that after a certain amount of time the ball stops.

    I have done many things like changing drag and angular drag while the ball gets lower in velocity, and all the known methods.. but this is not good enough.. the reason being that the game that i am making has trajectory prediction and changing these values, affects the quality of the projection.. so i need some way that wont affect a something like trajectory prediction..

    for example i tried covering the ball with small squares, so that friction can naturally effect it. but is very intensive and lowers the FPS Allot..

    is there any other solutions.. like making the spherical collider to have multiple contact points..
     
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,434
    For such accuracy I'd take the approach of disabling all Unity physics features such as drag, angular drag, friction, etc and leave gravity, mass and contacts only. Then I'd look for the proper formulas and calculate the actual drag and friction forces and torques myself out of the contact features (normal, force). This might give you more accuracy as you know exactly the forces and torques that you will be applying to the ball.
     
    EliJNemer likes this.
  3. EliJNemer

    EliJNemer

    Joined:
    Aug 3, 2019
    Posts:
    123
    thanks for ur reply,

    so how would i be able to predict the path to a good degree if i were to calculate all the forces in the game, manually.. that is to say that the collision detection system is of unity, gravity, and mass on..

    if i were to assume, that if i have a formula for the decrease in energy due to friction, if i wanted to simulate this i would do a
    for(int i .... ; x number of steps; i++){
    SimulatePhysics( xnumber of steps, timestep)
    add in here the formulas so that it mirrors
    }

    doing this every frame?
    and considering the work needed for each formula this could be taxing on the cpu or not.. but in general is it less taxing than doing this with the unity physics which might have thing i dont need?

    also is the collision detection good enough to count on for precision or should i also add my own collision detection?
     
  4. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,434
    Honestly I don't know, I haven't experience on this. But that's the approach I'd try if I had to. On collision detection, I'd keep using Unity collisions. Custom collision detection may become really complex in non-trivial cases.
     
    EliJNemer likes this.