Alternative Ball behavior

This forum is currently in read-only mode.
0 favourites
From the Asset Store
Template for an alternative to falling shapes, fully documented in comments and video
  • Hello.

    Tell me please, what methods do you know how to replace the standard Ball behavior, with similar functions? (for example, such as collision with solid objects and rebound from them)

    The problem is that I've found a nasty bug in the standard Ball behavior � sometimes during the game when the ball moves it can suddenly appear in another point of the screen (as if it jumps over some distance). This happens rarely (about once every 3-5 minutes), but it spoils the impression of the whole gameplay. This bug can not depend on the events, because there are no conditions or actions that control the behavior of the ball or a sprite at the time of his movement on the screen. So most likely this bug is a program error.. <img src="http://i987.photobucket.com/albums/ae352/constructgame/JD.gif">

    I've tried to create ball behavior by using Custom Movement, but it didn't recognize Solid objects, the Bounce function didn't adequately respond to the collision and creates a lot of bugs (often moves through the objects or even goes off the screen). He also moves very straightforward and often gets stuck between two objects unlike the Ball behavior. Therefore Custom Movement in this case does not suit me.

    So if you know any way to fix the bug with the disappearing ball or how recreate the original ball behavior - please write or make an example.

    Thanks in advance!

  • I think in this case you might be better off trying to replicate the bug, and reporting it to the tracker.

    Truth is its probably not that hard to make up your own movement, but there's no point in having the behavior if it doesn't work correctly.

  • Hmm, I made the ball with Custom Movement... no problems with it.

    Basically I added walls with Solid attribute, a Ball with Solid attribute and Per Pixel collision mode, tacked Custom Movement behavior onto it.

    Then I added a single event:

    + On collision between Ball and Wall

    Ball: Bounce off Wall (Friction: 1)

    (might want to set angle of motion and velocity at start so the ball actually moves)

    What is this bug?

  • Basically I added walls with Solid attribute, a Ball with Solid attribute and Per Pixel collision mode, tacked Custom Movement behavior onto it.

    I tried to make the ball with Custom Movement, but it moves very straightforward.. How to simulate the same random movement as in the Ball behavior? I.e. if the ball moving at an angle of 270, then bounces off the wall and moves back down, it must move at not 90, but 88 or 91 degrees, that will lead to a change in direction.

    I made the ball with Custom Movement

    Did you make the ball with this behavior because you had the same problem?

  • Yeah, Ball behavior is kinda glitchy. Personally I don't like the randomness of bounce angle; also, it behaves weirdly when you try to bounce off diagonal surfaces.

    We could use real ball physics (using maths to calculate collisions and stuff instead of pixel collisions). Then we could make accurate games such as billiards.

    But that's vector stuff.

    Edit: Well, I made a basic example:

    Seems that it is unstable in either case - Ball Behavior or Custom Movement alternative regardless, we get freaky balls. Oh well!

  • You could try the Physics behaviour. With linear damping at zero, elasticity at 100%, and collision mask set to Ellipse, it works in a similar way to the ball behaviour, but with better accuracy.

    Like this:

    http://dl.dropbox.com/u/906550/Construct/physics.cap

  • Hey,

    I tried to experiment with the Ball behavior and got the same problem as Mary Jane... then I tried downloading Mort's example but it makes Construct crash at startup (abnormal program termination, runtime error). I'm using 0.99.62....

    cheers!

  • I tried to experiment with the Ball behavior and got the same problem as Mary Jane... then I tried downloading Mort's example but it makes Construct crash at startup (abnormal program termination, runtime error).

    I very much hope that this bug will be fixed in a later version of the program.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Have you tried the latest build? I did slightly change the ball bounce algorithm in that, and I've improved it again for the next build - it actually seems much more reliable in the next build, so watch out for that and give it a try.

  • I suppose it must have crashed because I'm using a later version of Construct (I'm on 0.99.84).

    Here's the same file as an EXE. If the movement seems okay to you, it would be very easy to reproduce - just use the settings I mentioned earlier for the ball, plus you need physics objects with 'immovable' ticked surrounding the layout to prevent the balls flying off into space. Also, I used literally one event - at start of layout, add force 1500 to get the objects moving.

    http://dl.dropbox.com/u/906550/Construct/physics.exe

  • Have you tried the latest build? I did slightly change the ball bounce algorithm in that, and I've improved it again for the next build - it actually seems much more reliable in the next build, so watch out for that and give it a try.

    No, I have not tried 99.84, because I had read that you forgot to include David's fixes and other changes, so I decided to wait updated build with all fixes and more stable.

  • Has this problem been solved?

    I find a similar problem between a plateform behavior sprite with a rectangle shape and a ball behavior sprite with a circle shape.

    The circle (ball behavior) sprite will kick another outside the screen.

    here is my test case:

    http://dl.dropbox.com/u/5779181/collision_problem.zip

    Wait a moment, you will see the black sprite gone.

    (environment: construct 0.99.97 in winXP)

  • Couple of tutorials about game physics, collisions, elasticity, gravity etc.

    http://dl.dropbox.com/u/22173473/Collisions.rar

    Might be usefull ?

  • Has this problem been solved?

    I find a similar problem between a plateform behavior sprite with a rectangle shape and a ball behavior sprite with a circle shape.

    The circle (ball behavior) sprite will kick another outside the screen.

    here is my test case:

    http://dl.dropbox.com/u/5779181/collision_problem.zip

    Wait a moment, you will see the black sprite gone.

    (environment: construct 0.99.97 in winXP)

    I had a quick look at your cap, and noticed that your 'walls' are made out of box objects with a 'transparent' fill ? Thats why the player and wall collision isnt working. The box object's outline is not thick enough(pixels) for it to register a collision.

    Here's the cap file with the walls made out of a normal solid sprite.

    http://dl.dropbox.com/u/22173473/colisionprob2.cap

    The black sprite now has something to stop it leaving the screen.

    Hope this helps.

  • Thanks for this infomation about using sprite object to replace box object to make a boundary.

    Another question, where to use box object?

    In your cap, when black sprite idle(no keyboard pressed), it

    had not been push when ball sprite hit it. It looks like a wall to block the ball. How to do that?

    In my cap, the black sprite will be push back until ouside the window. I see the position x of black sprite is less then 0 in debug mode.

    If black sprite will not move whe ball hit it, it will not been push ouside the window. That is a good solution.

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