Weird bug with physics collision if other objects are created in loop at same time

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • I have an issue that seems like a clear bug to me but no idea how to solve it. In my game I have physics objects that are supposed to be paired with collision objects to make them land in different spots. As I tested I noticed that it worked well for about 10 seconds in my game and then things started to bug out with the collisions and the physics objects fell through their paired collision objects. It was not consistent though and if pausing for a bit and then creating more physics objects the collision could start to work again.

    I have isolated the issue down to the issue being caused by creating any other object in a loop. Please login to see this attachment.

    In my isolated example you create the physics objects by holding down the left mouse button. After the objects are created there is also a collision object created that pairs with the newly created physics objects fixed value and then an event to check for collision between them and trigger if they collide and their ID match.

    This works perfectly and looks like this:

    Please login to see this attachment.

    Please login to see this attachment.


    However.

    If I then add this loop where a loop is run 200 times each frame and creates another object (that is then destroyed) everything bugs out after a few seconds (usually between 5-10 secs)and the physics objects starts to fall through their collisions. If I keep holding down the mouse they continue to fall through and sometimes they work properly again for a few seconds before falling through again.

    Please login to see this attachment.

    Please login to see this attachment.


    Also I noticed something strange with the fixed value. The number in the top right is set to the physics objects fixed value and I noticed it seems to go negative for some reason for the "bugged" objects that fall through. Replacing the method of the fixed value with just an alterable ID value that is increased for each object produces the same results though.

    I have attached the mfa example. The first frame is the bug and the second frame is with the group that runs the loop to create the object disabled and thus working.

    Do anyone know why this is happening or how to fix it? :/

    Please login to see this attachment.

    Steam games: Please login to see this link.

  • Confirmed it does happen when negative. Perhaps there's a check for FV < 0 to check if a fixed value is valid somewhere?

    Please login to see this attachment.

    Darkwire Software Lead Programmer (C++ & C#)
    Please login to see this link. | Please login to see this link. | Please login to see this link. | Please login to see this link.

  • There are many problems with the example:

    1. The entire method isn't recommended, as you can simply store the random position in an alt value for the yellow object, and check if the Y position of the object surpases it, meaning no collision checks would be needed + simpler, faster, and more reliable
    2. Collisions are checked between a physical object, and a non physical object, which is a bad practice..
      While Fusion tries to add non physical objects to the world and check collisions, it ain't reliable, and problems can occur, like in this case, it's refusing to add the object to the world properly for it to be checked after FV is negative
      You should always check collisions between two physics objects, or go for an overlap check if really necessary
    3. Red casing is too thin, and the collision may be missed, especially if the display factor is big, velocity iterations are small, yellow object is going at a fast speed and/or on a low fps + Bullet collisions aren't checked for the yellow object, meaning even more chances of the collision being missed...
    4. In event 6, things can go very wrong because while you already selected the yellow object via the collision check, you doing it again for the red casing thing in the ID comparison...
      Basically, the event wouldn't work as expected if multiple red casing exist while a collision happens, because the selection is done in a wrong way..
      Fusion already selected multiple the yellow object via the collision check, for you to check the linked red casing, you should compare the ID of red casing to the Fixed Value of the yellow object, and not vice versa..
      Why? because in Fusions, expressions can only select a single instance at once, while the object picker can select multiple..
      Basically it's a multiple vs single situation, so if you already selected the parent, you now should select the child, but make sure you compare the children against the select parent and not vice versa... (That's also why foreach loops can be required for multiple vs multiple checks)

      Please login to see this attachment.

      Please login to see this attachment.

    Please go over the docs to understand how to deal with Box2D physics:
    There are 3 types of physics docs

    • Tutorials: Help > Tutorials (Quick Physics, and All Boxed Up)
    • Movement docs: Help > Contents > The objects > the commons properties > Movements > Physics
    • Physics objects docs: Help > Contents > The objects > Inventory > Physics objects

    (Physics object docs can also be accesed for each individual object by clicking the help button in the about property tab of a physics object)
    * There are also community resources that can be found on the discord, forum, and sites like Xable

    Game/App developer, artist and a community contributor.
    You can support my work on: Please login to see this link.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!