Suggestion for Ball behaviour + a physics bug

New releases and general discussions.

Post » Wed Aug 13, 2008 1:08 pm

You sure? Cause if there was a set X/Y component, I wouldn't be using variables and wouldn't have to override the velocity.I would be adding a certain value to the component's current value, not setting it to a fixed amount. Making it, to my understanding, so the ball will still bounce off obstacles.

So let's say when i press forward it adds 2 to my X component
Say the ball object is travelling at an X component of 50, i press forward, it takes the current X comp and adds 2 to it, making my ball object travel at 52 pps
Suppose then the ball collides with something, the ball behaviour, to my understanding then calculates the new angle of motion and adjusts the X and Y components, so let's say that after said collision, our X component is now -52
I press forward again and it adds 2 to the X component again making it -50
See where i'm going? This way, the current X/Y component is taken into account when moving the player. Is my thinking wrong? Did I explain myself properly?
Otherwise i WILL probably have to make my own custom movement.

The only problem I can see with making my own ball movment is I can't get the bounces and angle of motion after the collision as accurate as the ball behaviour does. As in, the ball behaviour seems to take into account the shape of the sprites, whereas i cannot find the shape of things using events very easily.

Anyways thanks for reading and all the work you're doin :)
B
3
S
2
G
5
Posts: 351
Reputation: 2,377

Post » Wed Aug 13, 2008 2:02 pm

If you want to add 2 to the X component only of the ball movement, then use:

set angle of motion (0, 0, Xvariable + 2, Yvariable)
set speed to distance (0, 0, Xvariable + 2, Yvariable)

As I said, those actions are identical to a 'Set X and Y components to Xvariable and Yvariable' action. You can retrieve the current X and Y components of the ball's movement via its expressions as well.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Wed Aug 13, 2008 9:47 pm

But the ball behaviour's X/Y components will change automatically upon collision would they not? whereas if i had to use variables i would have to find a way to calculate the new velocities
B
3
S
2
G
5
Posts: 351
Reputation: 2,377

Post » Sun Aug 17, 2008 9:56 am

It works with other behaviors, it should work with ball too.

But anyways, since it seems like i'm not going to be able to set the ball movements X/Y velocites, how does the ball behavior determine the angle of bounce?
Because I've got a custom movement set up and I really need ball/physics type bounces but those are dam hard for me to code.
Wouldn't it be cool to have some sort of generic 'bounce off object' type function, regardless of behaviour, where you put in the player object's X and Y velocites, and that of the obstacle (if it's even moving) and then construct does whatever it does to figure out the bounce direction for the ball and returns the new X and Y components for the player object which you would then have to store somewhere obviously.

I understand this is a pretty flighty, unrealistic and almost fictional suggestion, but it would be cool to be able to do realistic bounces (as in those that take into consideration the shape of the sprite) to custom movements. I'm not sure how you would go about it since the X and Y velocites would be stored in variables so if that system ever worked you would have to find a way to return two separate values which you can then assign to whatever you want.

If you're thinking, 'But Arcticus, just use the ball behaviour, it bounces fine', yes it does bounce fine, but not when it's angle of motion is fixed because of using varibles for X and Y velocites instead of editing the ball's X/Y components directly. Setting the angle of motion and speed i can do fine, it's the bounces that it stuffs up.

Here's a little example of what i mean if you don't get me, it uses the platform movement only to show that proper bouncing whilst using the Set X component and Set Y component is completely possible, please ignore the odd direction of the platform bounce as it is not intended to be used this way:

[url:381zkjvp]http://www.mediafire.com/?zr2keikuwnn[/url:381zkjvp]
Hopefully that conveys what I want :)
B
3
S
2
G
5
Posts: 351
Reputation: 2,377

Post » Sun Aug 17, 2008 5:39 pm

Well, that example has made me curious now if the addition is indeed needed. :?:
B
2
S
2
G
5
Posts: 391
Reputation: 2,432

Post » Mon Aug 18, 2008 12:01 pm

and on top of all that, the one thing that would be almost finish off the ball movement, as this example shows, is something a little more realistic than the current way if it bounces off something that hits it from behind...

[url:16uwa3o6]http://www.mediafire.com/?arrvjeumvri[/url:16uwa3o6] <-- See
B
3
S
2
G
5
Posts: 351
Reputation: 2,377

Post » Mon Aug 18, 2008 12:37 pm

Change Sprites attribute to Solids, mark the "Bounce off solids" and delete the collision event. It works now.
B
4
S
2
G
4
Posts: 719
Reputation: 2,938

Post » Mon Aug 18, 2008 12:46 pm

If i do it that way, only ONE of the ball objects bounces, what happens if you roll one ball slowly and then roll another ball faster into it?
the fast ball does indeed bounce off the slow ball, but the slow ball doesn't just continue on its merry way as though nothing happened.
What i was trying to point out in my example is that the bounces for the ball behaviour only seem to work well if it hits something, not if something hits it.
It's not an entirely huge problem, but a ball behaving like a ball would be cool ;) you know, newton's cradle and all that
B
3
S
2
G
5
Posts: 351
Reputation: 2,377

Post » Mon Aug 18, 2008 3:10 pm

[quote="Arcticus":339fe2s2]If i do it that way, only ONE of the ball objects bounces[/quote:339fe2s2]
lol both bounces.

[quote="Arcticus":339fe2s2]what happens if you roll one ball slowly and then roll another ball faster into it?[/quote:339fe2s2]
Bug report it.
B
4
S
2
G
4
Posts: 719
Reputation: 2,938

Post » Tue Aug 19, 2008 2:36 am

They will only both bounce if they collide when going opposite directions, if they collide whilst going the same direction it looks weird, which was my whole point
B
3
S
2
G
5
Posts: 351
Reputation: 2,377

PreviousNext

Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 2 guests