I have a wall in my 3D game which is relatively thin and it can be hit on both sides with objects that may occasionally be moving somewhat fast. Is there a reliable way to ensure that the colliding objects will be stopped on either side of the wall as opposed to simply passing through?

  • @Xenny
    link
    15
    edit-2
    1 year ago

    This one is easy

    You just record the position of the object from the last physics tick and raycast from that location towards the objects velocity direction and if the raycast hits a wall you just move the object back to the walls position.

    You usually want to add an additional check like this to all fast moving objects.

    • @[email protected]
      link
      fedilink
      61 year ago

      There is a builtin option in Rigidbody and I think also KinematicBody called continuous collision detection or CCD. It is supposed to do this for you, and with engine code (so much faster because it’s pure C++).

      However I have read some posts here and there saying it doesn’t work properly.

    • @MossBearOP
      link
      51 year ago

      This is a big help and makes a lot of sense! Thanks! :D

    • @Zoboomafoo
      link
      3
      edit-2
      1 year ago

      If you don’t do it like that, players will backwards long jump into a parallel universe