Ball Physics from Brick Breaker?

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.
  • Hi.
    I'm trying to make the ball movement similar to "Brick Breaker" games, but anything I try, it's total nightmare. Here are two examples:

    With "Bouncing Ball" movement:
    Please login to see this media element.

    With "Physics - Bouncing Ball movement" movement:
    Please login to see this media element.

    In both the ball movement is very unpredictable. Sometimes the ball just turns around (for example, the ball moves to the southeast, but when it hits the wall, it turns to the northwest), sometimes its direction just "stops" (the ball initially moves in different directions, but then it "slows down" and only moves either up and down, or left and right.. and might start from that too.. Sometimes the change is fast and sometimes really slow), and sometimes the ball just gets stuck in the wall, just like at the beginning of the first video.

    How can this be fixed, or can it be fixed at all?

    (PS: just ignore the duck with the platform.. focus on the movement of the ball)

  • Hello DuckJohnn,

    verify the ball movement mechanics, maybe you have some redundant events/conditions that make the ball path unpredictable or wrong.

    Try to isolate the movement logic into group of events, that you can easily activate/deactivate in your code, and see which one causes chaos to the ball movement.

    Regarding the continuously horizontal/vertical movement. This phenomen can be easily avoided in the ball movement property panel, when you decide which ball direction are allowed and which not. You can set it so that the ball will never travel with an horizontal or vertical path.

    By the way, that duck is cute :)

    Regards,

    Sergio

  • verify the ball movement mechanics, maybe you have some redundant events/conditions that make the ball path unpredictable or wrong.

    Only event I have related to ball is that when it collides with object that have certain qualifier, it bounces:
    Please login to see this attachment.

    Regarding the continuously horizontal/vertical movement. This phenomen can be easily avoided in the ball movement property panel, when you decide which ball direction are allowed and which not. You can set it so that the ball will never travel with an horizontal or vertical path.

    Ball is allowed to move horizontally and vertically, but only in certain situations. The ball should always turn at the angle it comes from.. just like light would work with a mirror.

    Like this:
    Please login to see this attachment.

    At the moment, the ball makes randomly its own decisions, like turning around or turning to another angle..

    Like this:
    Please login to see this attachment.

    For the "Bouncing Ball" movement, I've already set "randomizer" to zero. Even after changing "# of angles" to 8 (just for testing), the ball still makes sometimes a complete turn, or turns horizontally/vertically from an angle.

    The balls "course" is supposed to only change when it touches the platform (carried by the duck) depending on where the ball hits, but I'll do that later.

  • Only event I have related to ball is that when it collides with object that have certain qualifier, it bounces:
    Please login to see this attachment.

    Perhaps the ball collides more times with different bricks, thus it "bounces" more than one time. You may set a flag for the ball, for example "alreadyBounced". When the ball bounces the first time, set this flag to true. By the next collision, if the flag is true, do not let the ball bounce again.
    Then, when the ball does not collides anymore with any brick, you can set the flag "alreadyBounced" to false.

  • I already tried that, but it didn't work. The problem occurs even if the ball hits the middle of the block without touching the other blocks.

    What happens if you subsitute all the bricks ( walls, ceil and floor ) with a single active object as a squared frame, transparent in the middle ?

    That way you can test the ball bouncing against a single object - which is that squared frame.

    If the bouncing works as expected, then the problem resides in the bricks..

    Make a new blank frame from within your project and test that..

  • Hmm.. I don't notice any differences.. (this also happends when I make event (ball leaves the area => bounce):
    Please login to see this media element.

    Even if the edges of the game area were one and the same object, or multiple larger objects and the problem was fixed, it would not fix whole problem, because it also occurs in breakable blocks, and those can't be change to the single object.

  • The Bouncing Ball Movement Properties

    The bouncing ball movement makes your object move like a ball that bounces on the obstacle. It is a very handy movement that can be used in a variety of ways, not only for balls (examples, enemies, goals etc.).

    The properties of the bouncing ball movement are as follow:

    Speed
    Sets the speed that your object will move at, from 0 (static) to 100 (full speed).

    Deceleration
    Sets the amount of friction working against your object. By default, deceleration is set to zero so that the ball will bounce on a surface without friction. If you increase the deceleration, the object will lose speed as it moves and will eventually stop.

    Moving at start
    Enable to have your object moving when the application begins.

    Number of angles
    This combo-box gives you 3 choices, 8, 16 and 32. These values represent the number of allowed angles for your object. The more angles that you select, the smoother the bounce effect.

    Randomizer
    Gives the ball a random chance of bouncing in different directions. The higher the setting, the more varied the effect. If you would prefer predictable rebounds, turn this feature off by sliding the randomizer all the way to the left.

    Security
    Prevents the object to be stuck in a bouncing loop by a applying a random bounce after a certain amount of similar bounces.

  • DuckJohnn,

    you should try to isolate the problem in order to solve it.

    As previously said, if you test the bouncing ball against a single active object, and the ball bounces as expected, you then know that the logic behind the bricks is faulty.

    Once you prove that, you can maybe rethink that logic.

    You may for example have a single object for the bouncing against the bricks, so that the ball bounces right, and you can have another hidden ball behind the visible one, and use it to delete the brick(s) when it collides with it.

    This way the visible ball will bounce as expected, and the bricks also are destroyed as expected.

    I hope it makes sense for you.

    We are glad to help, but you should do and try what we suggest you.

    Take care,

    Sergio

  • FYI this object has never 'worked' as intended since I can remember. You get better results from coding your own engine. Or perhaps the collision mask is to blame? Really is hit and miss for want of a better phrase.

    Regards

    Ross

    Please login to see this link.

  • As previously said, if you test the bouncing ball against a single active object, and the ball bounces as expected, you then know that the logic behind the bricks is faulty.

    but you should do and try what we suggest you.

    I tested it several times in several different situations, but the ball doesn't bounce as expected. I already said yesteday that I saw no difference. Nothing got changed.
    The breakable blocks have exactly the same logic as borders.. nothing special: (ball collides object => bounce).
    Only, and only difference is that when the ball touches the block, the block gets destroyed. This event happends before the "bounce event" happens.

    You may for example have a single object for the bouncing against the bricks, so that the ball bounces right, and you can have another hidden ball behind the visible one, and use it to delete the brick(s) when it collides with it.

    This way the visible ball will bounce as expected, and the bricks also are destroyed as expected.

    The problem is not about breaking the blocks, but about how the ball bounces. Breaking blocks works perfectly just as inteded.
    The ball just turns around randomly, whether the block gets destroyed or not, whether it bounces from breakable block, the wall, or the border of the area.

    FYI this object has never 'worked' as intended since I can remember.

    I've been using Clickteam for almost 10 years, and I have noticed similar problems in many different situations..

    You get better results from coding your own engine

    Possibly, but I know nothing about real coding and I don't want to go learn it just for this little side project.

    Or perhaps the collision mask is to blame?

    I already tried box shaped collision and ball shaped collision, but without luck.

  • I have an idea, since the ball seems to bounce right against the destroyable bricks, you may use the same bricks for the walls, ceil and floor, and don't destroy them by bouncing.

    This way - again, assuming that the bouncing against the destroyable brick works - the ball should bounce overall as expected..

  • I never actually had any real issues with how the bouncing ball movement worked, it should bounce accurately as long as the randomizer and security are set to 0, the shape of the ball / obstacle is not weird (note that you should not expect it to understand things like slopes very well)

    Also, don't know if it helps, but here is an easy to use widget of a custom bouncing ball movement I made before, complete with multiple instance handling, deltatime, and step checks (no need to understand the core events to use it): Please login to see this attachment.

    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!