Bouncing Balls go horizontal/vertical
crestwoodgames
Member Posts: 191
Messing around with a game that has a lot of bouncing balls. Their angle starts out random, never vertical or horizontal. As they bounce around the screen they eventually go horizontal or vertical.
On my wall actors I have movable unchecked and all other physics attributes set to 0. Only the ball has a bounciness of 1.
Any ideas on how to fix this. I know I could do a horizontal/vertical fix, but don't understand how this happens.
Comments
You mean if they get close enough to parallel with the walls they just start "sticking" to the walls instead of bouncing? I submitted a bug report for this, but who knows how long until it's fixed. http://bugs.gamesalad.com/show_bug.cgi?id=1513
If you only have vertical and horizontal walls on the edges of the screen, this is an easy fix. Stop the balls from colliding with walls, and make a rule in the ball actors that says if overlaps with left or right wall, negate linear velocity x. If overlaps with upper or lower walls, negate linear velocity y.
What do you mean negate the linear x or y?
I think he means multiply it by negative 1
I am not using a formula for the bounce. I am letting the physics engine take care of it. As of now I have to put in rules in the actor to correct any Horizontal/Vertical issues, but it does not look good.
Just not sure why it would do this.
@crestwoodgames I know you're using the physics engine, and I'm saying that's where the problem lies. It is a bug. If you use custom bounce rules like I said, the problem should go away.
You can also add a couple rules to the balls that check their velocity X and Y and if they are equal to zero change it to something else when it hits a wall so it bounces off at an angle.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
@Rainbros OK, I see what you are saying. I will look into some formulas.
@jamie_c I will give this a try.
Thanks for giving some Ideas!
@jamie_c I like this method, but have run into a little issue.
I have a rule that states if linear velocity Y is between -50 and 50, change to +5. This works great unless I am moving in the negative direction. Same goes for the X axis. I was trying to figure out a formula that could take the direction the balls was moving and nudge it by 5 in the same direction.
But, I am not a math wiz and cant figure it out. I am sure its probably something simple.
Have you tried this method before?
Multiply by 1.1 ?
50 x 1.1 = 55
-50 x 1.1 = -55
@RThurman oh yeah. I knew that thanks! woks like a champ!
Great!
I had a similar sticking-to-the-walls problem recently. Turned out I hadn't changed the collision shape to circle on the balls. That fixed that one. Adding a tiny bit of bounce to the walls helped too.