Destroy ball object after two bounces

This forum is currently in read-only mode.
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • Sorry, I know I asked this in my other post but I felt like it'd be better off to make a new post about this.

    I can't seem to figure out how to destroy the ball object after it has bounced two times. Not only that, but I want to make it so that a sound effect plays every time it bounces off of a wall.

    I was thinking of making is so when the ball collides with a solid, it rasies a private variable up by 1. Then when it gets to a certain value, it destroys itself. But that doesn't work. The value stays at zero even when it collides with the wall. It doesn't play a sound effect either, no matter what I do.

    There doesn't seem to be an event option to check for if the ball has "bounced" or not. Maybe I'm wrong. But I can't seem to figure out how to do this simple thing in Construct. Could anyone help me out?

  • There doesn't currently seem to be any way to test for collision directly with a ball object. You can make a second, invisible sprite slightly larger than the ball, and put it on top of the ball and test for collisions that way.

    It would be nice to have a ball behavior condition that tests for collision though (there aren't any ball behavior conditions at all currently). Or simply make the sprite collision condition work in tandem with the ball behavior. You might want to hit up the feature request thread.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hmm... well, what happens is the 'Bounce off solids' option in the ball movement, when ticked, automatically moves the object off the solid and changes the direction. Because it's moved off, by the time the 'On collision' event comes to be tested, it's still not overlapping.

    Deadeye's solution could work, or you could try turning off 'Bounce off solids' in the ball properties. You can then add an event - ball collides with sprite - and add the 'Bounce off object' action in the ball to bounce it off. Then you can add your own actions to the event as well, like playing sounds and incrementing counters. I just tried it, though, and the collisions are a little less accurate this way. You might need to make the bullets slower.

    I think I can fix this for a future build though - so if the ball registers a collision when deciding if it should bounce, then it should also register a collision in the events. This might get physics objects to register collisions as well...

  • I think I can fix this for a future build though - so if the ball registers a collision when deciding if it should bounce, then it should also register a collision in the events. This might get physics objects to register collisions as well...

    Yes, yes, a thousand times YES! If you could do this I would be ecstatic.

  • I second that notion. I hope to see this fixed right away. Thanks Ashley.

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