Three Physics expressions don't work with circular collision masks. (I guess it is a bug)

0 favourites
  • 10 posts
From the Asset Store
Is a circular loading screen with code ready to use. No Animation.
  • When the colliding sprites have the "Physics" behavior, are not immovable and their collision mask is set to "Circle", these three expressions do not work because their value is always 0:

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • It works for me. Can you show your code?

  • It never works for me, in any game.

    Here's a very simple project isolating the problem: fileport.io/4YaDKypQ3nKh

    Check it and you will see that those three Physics expressions almost never work.

  • Thanks for the example!

    I get mixed results, sometimes 0, sometimes data.

    I think in this specific c3p, it's due to "on collision" trigger.

    Correct me if I'm wrong, but, each tick, triggers process first, then event sheet, then physics.

    Perhaps the "on collision" gets data too early, resulting in 0. But it would give data if the objects touch for more than 1 tick.

  • I'm also getting mostly 0s, but occasionally I get values. When I get a value it's mainly when barely hitting like a glancing hit.

    Why? Who could say, but it seems like the contact points are available on the following frame (construct has too many things that are only calculated at the end of a frame).

    So, a user fix could be to do events like this:

    every tick:
    -- signal "nextFrame"
    
    Ball1: collides with Ball2
    -- wait on signal "nextFrame"
    -- ... get contact info

    I suppose you could still miss hits if physics detects a collision with the circle, but construct doesn't detect a collision with the polygon since they both have their own collision detection.

    Another idea could be an expression like:

    Ball1.Physics.ContactCount>0

    and you'd get contact points from ball1 hitting anything. You could find what was hit as a secondary collision check.

  • Your example is just working here and there for me too.

    Ball1.Physics.ContactCount>0

    That works consistently for me, this is 100% the way to go. I suggest you can call a raycast here towards ContactX/Y (+ some extra distance otherwise the raycast may be too short) if you need to know what exactly was hit since you can get the UID of the hit object like that.

  • Thanks everyone for your replies.

    every tick:
    -- signal "nextFrame"
    
    Ball1: collides with Ball2
    -- wait on signal "nextFrame"
    -- ... get contact info

    R0J0hound This fails sometimes.

    Ball1.Physics.ContactCount>0

    R0J0hound This seems to work fine. Thanks.

    WackyToaster Thanks for the idea.

  • I just discovered that, curiously, the result improves considerably when I simply check the "Bullet" box in the Physics behavior of the balls:

    Maybe some expert knows why.

  • Hmm good question. The bullet setting adds more steps in the physics engine, so it's probably simply that more steps = more chances that when the collision triggers in Construct there also happens to be a collision in the physics engine. Without trying I'd suspect though that it's still not 100% reliant because the physics engine treats the shape as a perfect circle whereas Construct just uses the collision poly.

  • Hmm good question. The bullet setting adds more steps in the physics engine, so it's probably simply that more steps = more chances that when the collision triggers in Construct there also happens to be a collision in the physics engine.

    That makes sense.

    Without trying I'd suspect though that it's still not 100% reliant because the physics engine treats the shape as a perfect circle whereas Construct just uses the collision poly.

    No, it is not 100% reliant.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)