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. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    Dismiss Notice

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


    Nov 24, 2013
    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.

    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:

  2. Edy


    Jun 3, 2010
    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


    Jul 28, 2012
  4. Arnold_2013


    Nov 24, 2013
    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.

  5. JosepMariaPujol


    Unity Technologies

    Jun 16, 2021
    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


    Nov 24, 2013
    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.