Alternative Ball behavior

For questions about using Classic.

Post » Wed Mar 03, 2010 4:41 pm

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..

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!
B
3
S
2
G
3
Posts: 146
Reputation: 1,567

Post » Wed Mar 03, 2010 5:20 pm

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.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Wed Mar 03, 2010 6:02 pm

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?
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Wed Mar 03, 2010 6:23 pm

[quote="Mipey":6df3v8gd]Basically I added walls with Solid attribute, a Ball with Solid attribute and Per Pixel collision mode, tacked Custom Movement behavior onto it.[/quote:6df3v8gd]

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.

[quote="Mipey":6df3v8gd]I made the ball with Custom Movement[/quote:6df3v8gd]

Did you make the ball with this behavior because you had the same problem?
B
3
S
2
G
3
Posts: 146
Reputation: 1,567

Post » Wed Mar 03, 2010 6:27 pm

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: viewtopic.php?f=16&t=5890&p=47063#p47063

Seems that it is unstable in either case - Ball Behavior or Custom Movement alternative regardless, we get freaky balls. Oh well!
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Sun Mar 21, 2010 2:49 am

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
B
5
S
2
G
4
Posts: 113
Reputation: 2,101

Post » Wed Mar 31, 2010 8:56 am

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!
Image Image Image
B
82
S
21
G
8
Posts: 163
Reputation: 11,516

Post » Wed Mar 31, 2010 9:50 am

[quote="roberto":3twqnrbu]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).[/quote:3twqnrbu]

I very much hope that this bug will be fixed in a later version of the program. :roll:
B
3
S
2
G
3
Posts: 146
Reputation: 1,567

Post » Wed Mar 31, 2010 9:59 am

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.
Scirra Founder
B
359
S
214
G
72
Posts: 22,951
Reputation: 178,578

Post » Wed Mar 31, 2010 10:44 am

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
B
5
S
2
G
4
Posts: 113
Reputation: 2,101

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests