Bounce ball issues help
Jogos_TDA
PRO Posts: 46
I am creating a game where the ball needs to bounce inside a box like in ping pong game.
The problem is: after a few bounces, the ball seems to stabilize and bounce back and forth at the same place.
It seems like the ball is "square".
I already searched the forum and google for a solution but got none, except to make collision shape "circle", but that did not solve the issue.
The ball image is transparent square. Is this the problem? If so, how can I make its image round, without any transparent square borders?
Any help is appreciated, thanks.
The problem is: after a few bounces, the ball seems to stabilize and bounce back and forth at the same place.
It seems like the ball is "square".
I already searched the forum and google for a solution but got none, except to make collision shape "circle", but that did not solve the issue.
The ball image is transparent square. Is this the problem? If so, how can I make its image round, without any transparent square borders?
Any help is appreciated, thanks.
Comments
That's the general idea, but obviously not specific code. Hope it helps.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
Can you post a screenshot of your movement & physics attributes?
Here is a video to illustrate what happens:
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
I am checking it now, but in your code example the ball is getting stuck also...
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
I changed the condition from self.motion.linearvelocity.y from 0 to between -2 and 2 and now it works perfectly!
Thanks for your help bro!
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
Although @jamie_c's fix works, that behavior shouldn't be happening. Based on the video, I think your physics settings are a bit wacky. If you post your project, I can take a look for you.
After another look at physics settings I found out that when I use friction at about 3 level, it will make the ball slow down after its bounce and cause the ball to get eventually stuck at vertical or horizontal level...
Here is the code for the basic version with the solution implemented, but it seems not to be working yet. I have added the 'display text' for linearvelocity.y
Yep, you pretty much said it...
The bounciness set to 1.5 is the cause of the trajectory interruption and thus eventually ending up stuck like in the video.
The friction at level 3 is indeed slowing the ball down but not the cause of it getting stuck.
The simplest solution I think would be to set bounciness of ball and walls to 1 and paddles to let's say 1.25 or more, you should get a nice speed up effect with chances of getting stuck next to impossible.
I would like to use 'accelerate ' to increase the ball velocity instead of using 'bounce' to do that.
But the problem is that when I use 'accelerate' I have to input the direction the ball is going at that time and I dont have that...
Here it is;
Now the only missing puzze is how to find the angle that th eball is going.
I'm trying to make up a formula using linearvelocity.x and linearvelocity.y
Yes, you can figure out the direction your going using something like:
vectorToangle(last.position.x - position.x , last.position.y - position.y)
where last.position.x & last.position.y = position some amount of time ago OR some amount of distance ago
but... I think your better off with bounce as the above is not trivial.
1) ball speed
2) ball linearvelocity.x
3) ball linearvolocity.y
Still the only missing puzze is how to calculate the ball angle...
Have fun with the file (attached).