Weird behavior with bullet bouncing on solid

0 favourites
  • 4 posts
From the Asset Store
Bouncing ball
$9.99 USD
Template for a bouncing ball game, fully documented in comments and video
  • Hi !

    http://canapin.com/construct/canagolf/01/ (mouse + click)

    Bullet, angle, speed, bounce on a solid. That's pretty straightforward.

    However, the bullet behaves strangely when it bounces in inner angles.

    The ball sometimes seems to "jump" or teleport for a short distance in these cases.

    Give a couple of tries here for example :

    It also happens on the four inner angles of each layout angle but it's harder to see.

    Here are my events :

    And my capx : http://canapin.com/construct/canagolf/0 ... lf-02.capx

    Any idea ?

    edit : I tried with time scale to 0.2 and I can clearly see the ball teleport for a short distance in some case.

    I need a precise behavior… <img src="{SMILIES_PATH}/icon_e_sad.gif" alt=":(" title="Sad">

    Should I switch to physics behavior in order to have better collisions ?

  • The teleportation is due to the method C2 resolves the collision. You can use the two ways from the custom movement behavior's push our actions.

    One is "push out nearest" which searches in a spiral like path around the object until a free spot is found. It works pretty well most of the time but in tight spaces like you have it can find a spot which isn't the nearest.

    Another is the object moves backward until it's no longer overlapping. That works well except after the bounce. The issue is the backward motion is in steps and after a bounce the backward step could be too much so instead of stepping back to the starting position it could pass it back into a solid so it effectively could tunnel out.

    The physics behavior is a simple way to have better collision resolution in that case. Or you can also do it all manually to have full control and in many cases have better results.

    I'll see if I can wip up an example. A simple idea that strikes my fancy currently would be to do the push backward idea except keep it from pushing back further than the old position.

  • Here's an example:

    https://www.dropbox.com/s/eftq33ve74rul ... .capx?dl=0

    It's actually three parts. The first is to move the ball. The second is to move the ball backwards out of the walls. The third is to calculate the normal from the ball to the walls so we can calculate a bounce. It's an approximation that may or may not be good enough.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you very much !

    I chose the physics behavior, easier to use.

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