Search Unity

What else is to be done if player falls through the floor?

Discussion in 'Physics' started by unitedone3D, Dec 27, 2020.

  1. unitedone3D

    unitedone3D

    Joined:
    Jul 29, 2017
    Posts:
    160
    Hey there! If we have a player and when he walks around, he sometimes 'collides' with objects...but especially, the small mountains/butes....like if I move around a 'push' on purpose on the floor...I fall through it.

    This is clearly a collider problem....but I don't understand, there is a mesh collider on the ground...and it still does that...I tried making a 'box' collider. instead..., it seems that works better; but even there the player 'may go through a floor/object'...with 'pushing on it' continuously..thus, object/player intersecting problem.

    This is realted to the physical engine...I am starting to think these are natural limitations of hit collision (of this physixs engine), I read that the Havoc engine could mitigate that..but how do you 'proof' the floor to never make the player go through/fall through it by gravity...I noticed when I crouch in the game...and 'push' repeatedly,
    the engine can have difficultly and then I fall through the floor...like as 'Update' and 'Fixed Update' for the physic engine (in Project settings > Physics)...can't keep up and so CPU may 'skip' a frame calculation and so the object 'passes through/intersects' and can literally 'Fall' trhoguh the floor...

    I tried several different settings in the Physics project settings....made no difference; I activated 'collision callbacks', dynamic collision, and so forth tried them all..all of them makes player fall through floor.
    It is as if the Mesh Collider on the ground/floor is 'transparent/empty/non-blocking surface' by times...and only works if you 'don't push' too much on the floor...like crouching and moving like crazy...

    If I walk slowly and just 'forward' never pushing down on the floor...it works...like just that...as soon as I jump, do crouching, crazy moving..then I fall through...the physics engine can't keep up with the movement collisions if 'it,s too fast/too much', so that is when 'objects/player' go through each other/intersect and 'falll through floor' in a endless fall (by gravity)...

    I tried with more physics iterations/calculations CPU....which slows down frame rate but makes a more precise physics hit collision calculations...made no difference.

    How can we make the floor 100% 'waterproof/fallproof/untransparent', so that the player Never Falls Through the flloor...

    I read that there is not much to be done about this problem; like there are some scripts that helped, I added several 'box colliders' under the ground/floor..and that works...but I still can 'go through' mountains/butes/duners....if I push in them...if I go through them, only the invisile 'under the floor' colliders 'hold me' from falling by gravity..but I'm still 'out of the floor'...walking in the air on an 'invisible' box collider

    I am thinking only switching with Havoc physics engine might solve this...because the PhysiXs Unity physics engine is not capable (it seems?) of making the player/objects Not intersect and fall through each other during the intercollisions of their respective surfaces....

    Any help is greatly appreciated and happy holidays/new year 2021! Thank you very much.

    PS: ''continuous detection modes'' for collisions...tried them all. not working.
    ''change Update to FixedUpdate''...tried, no difference.
     
    Last edited: Dec 27, 2020
  2. tjmaul

    tjmaul

    Joined:
    Aug 29, 2018
    Posts:
    467
    With enough force applied to a rigidbody, it can unfortunately pierce through other objects because all the physics engine does is to separate overlapping objects. I can only assume that you’re either using transform.position = .. to move your character (you shouldn’t) or you add a strong force down when you crouch (you shouldn’t) or the size of your objects are completely off. The default settings of the physics engine parameters work well for “life sized” objects. So make your character 1-2 units tall, not 0.001, not 100000.

    you can also post some of your movement code for further inspection
     
    tree_arb likes this.
  3. DPunK

    DPunK

    Joined:
    May 15, 2019
    Posts:
    25
    Like tjmaul said, this can happen when pushed to extremes but really should not happen by default
    Can you describe the setup here and the forces pushing against the floor?

    In addition to what tjmaul suggested I think it's worth to check what the fixed time step is in the settings (Preferenes > Time if I'm not mistaken). By default it should be 0.02
     
    Last edited: Dec 27, 2020
  4. tjmaul

    tjmaul

    Joined:
    Aug 29, 2018
    Posts:
    467
    Shouldn’t that be 0.02?
     
  5. DPunK

    DPunK

    Joined:
    May 15, 2019
    Posts:
    25
    Yeah, fixed that