Physic2D and collision detection

Not favoritedFavorited Favorited 0 favourites
  • 4 posts
From the Asset Store
Particles support animations, collisions, effects and etc.
  • (>> physic2d behaviour add the collision angle expression)

    I have a ball that bounces off walls with a value of 1, but when I try to detect the collision as it bounces off the paddle for a brick-breaking game, it's delayed due to the 60 frames per second limit. I absolutely have to maintain 60 frames per second and use V-Sync.

    To test it, when there's a collision, I disable the ball, and after that, it has already started bouncing. How can I fix this problem and ensure the event triggers precisely at the moment of collision without any delay?

    I need it to make it bounce differently and manually.

    The best way to solve the problem would be to add the collision angle expression, as in lineofsight in raycast mode. The ball doesn't bounce, but when there's a collision, we make it bounce and not before; this synchronizes with the collision detection speed.

  • I do something similar in Flippee Ball - if the ball hits an AI's flipper, I predict the ball's trajectory and if it's going CLOSE to the basket, I tweak the trajectory so that it goes INTO the basket. Neither the fact that this happens just AFTER the collision or the changed trajectory itself are noticable.

    What I don't understand about your case is what problem does it give you if there's a slight delay in reporting the collision?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Things move in steps so the collision will almost always happen after objects overlap a bit. The behavior runs before the event sheet does so it makes sense that the behavior already resolved the collision and bounced the object.

    There are ways to detect the exact time a collision occurs but it mostly involves rolling your own physics engine. But beyond ball vs box collisions could get involved.

    If all you want is to have more control over the bounce angle you could save the velocity to a variable at the end of every tick. Then above that you could check for a collision and you’d have the before and after velocity and you could calculate the collision normal from that.

    You could also move the object backwards after a collision till it’s barely touching to get a more exact point of collision. However the way physics engines resolve collisions can be a bit inexact. They first push the objects apart, then calculate the bounce. If you saved the position before a collision you could use the loop idea to move forward to get a point of collision to avoid the push out inaccuracy. At that point we are using much less of the physics engine and mostly are using it for finding the collision normal.

  • In 60fps and vsync enabled, if i do every 120fps (with x seconds condition) ceck collision with paddle, it's simpler?

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