Search Unity

Question How to stack cubes stably with Unity Physics in ECS1.0 (without pro license)

Discussion in 'Physics for ECS' started by Arnold_2013, Dec 28, 2022.

  1. Arnold_2013

    Arnold_2013

    Joined:
    Nov 24, 2013
    Posts:
    285
    TL; DR: Is there any way to make "Unity Physics" stack stable towers?


    So from this forum post it seems confirmed Havok is not an option for me, with its ~2k euro/dollar per year price.

    https://forum.unity.com/threads/confusion-and-question-2022-2-ecs-and-havok.1371255/

    So what are my options? I am making a single player VR game with stacking blocks on top of each other is a main feature. But as you can see in the linked video the 'free' unity physics is just not able to cope with stacking.

    Left : Unity Physics 4 iterations (just keeps rotating)
    Middle : Unity Physics with 8 iterations (one of the bottom blocks pops out)
    Right : Havoc Physics 4 iterations. (just works)

    There is no recoil force or any other force acting on these tower blocks. I cannot increase the (angular)drag to infinity, since throwing the blocks is also a feature. I don't want to 'snap' connect the blocks because building/changing these towers under pressure is one of the features.

    After having my steam page up for more than half a year, I have 100 whish lists so I don't feel I can recoup the cost realistically at this point.

    Is there any way to make Unity Physics stack stable towers? They need to stop moving when nothing is toughing them. I know I am asking very much from a modern physics engine to deliver 'the stacking of cubes', but until now I was allowed to build with Havok so this issue was not on my radar.


    These are my Unity Physics settings:
    UnoityPhysicsSettings2022_Iterate8.PNG





     
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    As far as I know, Unity Physics is stateless by design: it doesn't carry over any extra information from previous steps in the calculations for the current step. It just takes whatever state the physics objects are in, resolves collisions, integrates the forces/torques and computes a new state.

    On the other hand, Havok does some caching so it's "aware" of the stacked objects and process them accordingly to the expected result.
     
  3. TheOtherMonarch

    TheOtherMonarch

    Joined:
    Jul 28, 2012
    Posts:
    866
  4. Arnold_2013

    Arnold_2013

    Joined:
    Nov 24, 2013
    Posts:
    285
    I've enabled the heuristics and increased the iterations to 8 for the 'middel' situation in the video.

    Hmmms I could try to mess with the values of the heuristics, but they do say in this thread that the default values are sensible.
    "All these individual parameters default to sensible values that should work in most cases and are only exposed to fine tune some specific scenarios we might have forgotten to cover."

    Increasing the threshold values could also result in un-stable stacks not falling over because their induvidual velocities keep getting clipped to 0.

    Thanks
     
  5. JMPM-UNITY

    JMPM-UNITY

    Unity Technologies

    Joined:
    Jun 16, 2021
    Posts:
    93
    Hey, @Arnold_2013 there is a way to make "Unity Physics" stack stable towers. It is called
    Enable Contact Solver Stabilization Heuristic within the PhysicsStep authoring component. There was a regression in the code that made it disappear from the public eye but in the upcoming release, it will be back.
    See picture.
     

    Attached Files:

  6. Arnold_2013

    Arnold_2013

    Joined:
    Nov 24, 2013
    Posts:
    285
    Thanks for pointing this out, but I already has this selected (as shown in the screenshot).

    To work around the problem I scaled up my entire game (all the entities + terrain) with a factor 5 and now the stacking with Unity Physics is oke. I guess the scale influences the friction (friction 0.89 + Maximum)... maybe. I also increased the mass by a factor 10, but kept the gravity the same at -9.81...

    So with 1x1x1m, mass 100, 0.05 bevel radius the tower is not stable. But with 5x5x5m, mass 1000 and 0.25 bevel radius it is. o_O
    With the heuristics it makes sense that being above or below the cutoff makes all the difference. Its just that a 1m3 cube seems like a normal sized object.

    Its a VR game, so the stacking of the new blocks is done with human inaccuracy in position and velocity.
     
    daniel-holz likes this.