Search Unity

Question Downwards force is creating friction even with turning it off

Discussion in 'Physics for ECS' started by Cell-i-Zenit, Nov 27, 2020.

  1. Cell-i-Zenit

    Cell-i-Zenit

    Joined:
    Mar 11, 2016
    Posts:
    290
    Hi,

    so i have a system which will create a downwards force for each entity.

    The problem i have is that when an entity is walking on ground, the friction is really strong. The moment my entity jumps up, if moves much more forward, then moving on the ground.

    I tried to turn of the friction of my player, but this doesnt result in any change.

    I also tried to turn of the friction of my "static" ground objects, but this didnt result in any change.

    Can you help me?
     
  2. Leonardo_Temperanza

    Leonardo_Temperanza

    Joined:
    Aug 18, 2014
    Posts:
    7
    How does your "downwards force" system work? Are you simply modifying every PhysicsVelocity component inside the OnUpdate method kind of like this?

    Code (CSharp):
    1. Entities
    2.             .ForEach(
    3.             (ref PhysicsVelocity Velocity) =>
    4.             {
    5.                 Velocity.Linear -= new float3(0.0f, 0.1f, 0);
    6.             }).Run();
    Is the ground a simple flat surface or is it a very tessellated/complex mesh with slopes?
     
    Cell-i-Zenit likes this.
  3. petarmHavok

    petarmHavok

    Joined:
    Nov 20, 2018
    Posts:
    461
    The answer above might give a clue, it also depends when you do this change, it might be overriding the results of the physics step.

    Another thing to look at is the friction combine policy. If you want 0 friction, you need to make sure the character and the ground have values and combine policy so that you effectively get 0 friction. For example, if character has the policy set to MAX and friction set to 0, it will effectively get the friction of the ground which could be non zero.
     
    Cell-i-Zenit likes this.
  4. Cell-i-Zenit

    Cell-i-Zenit

    Joined:
    Mar 11, 2016
    Posts:
    290
    Sorry for the late reply:

    yes i have a gravity system which is applying a custom continuous force in a direction, exactly like yours.

    The surface is multiple cubes, aligned to create a floor, the player and the cubes have both friction to 0 and minimum set.

    When i disable the downwards force then everything works as expected (0 friction)
     
  5. steveeHavok

    steveeHavok

    Joined:
    Mar 19, 2019
    Posts:
    481
    Double check that your bodies are ending up interpenetrating because of the downward force. If they are then this will lead to a penetration recovery impulse regardless of friction values. If you have a very small Bevel Radius on your Physics Shape then interpenetration can happen more easily, so you could try increasing the Bevel Radius.
     
    Cell-i-Zenit and petarmHavok like this.
  6. Cell-i-Zenit

    Cell-i-Zenit

    Joined:
    Mar 11, 2016
    Posts:
    290
    I did it!

    the problem was that i still had a box collider component on each object. Removing them, results in the expected behaviour :)

    thanks for your help
     
    petarmHavok likes this.