Problem with the primary mechanic of my game.

The game: A more-advanced breakdown clone. With a platform that can be angled, and moved left and right by the players control.

The goal: To make a mechanic that allows the ball to bounce around the level with zero friction and a constant velocity that can change directions as it bounces around.

Current mechanic: The idea is to have a ball that is launched at a starting velocity, and to avoid having any resistance force applied to it. This is done, as stated by launched the ball with a force of 300, in a starting direction, the ball then bounces off of all elastic obstructions, and continues this as it collides with, and destroys blocks as an objective.

The problem: Numerous variables constitute to the overall slowdown of the ball overtime, that I can’t seem to eliminate. Another issue is that if the platform that the player controls is in motion while the ball collides with it, the ball is accelerated at very high speeds. It makes sense as to why this happens, I just don’t want it to happen. And the final least prominent issue; Sometimes when the ball hits a surface parallel to the direction it is traveling, it will come to a dead stop, or slow down, regardless of both objects being 100% elastic, and having no dampening.

Alternative mechanic that has issues: An alternative would be to use a ray and calculated the direction it needs to travel if colliding with an object, this would allow my to apply a constant and controlled force to the object. The problem is that I cannot get this system to work, regardless of the numerous scripts that exist for it.

So, can any of you guys help me to find a solution for this conundrum? I would prefer the alternative solution, but a fix for the original would still be good.

I have attached a demo of the mechanic in a simplified state:
demo2.blend (646 KB)

if own.localLinearVelocity.magnitude<30:
own.localLinearVelocity*=1.05

Uh, what is this for? I have quite a few issue…

ok

try this :smiley:

Attachments

Reflect.blend (422 KB)

With a simple game like pong or breakout it might not work that well to use advanced physics.
Those old games used simple math to calculate movement of the ball and it worked well because the movement was quite predictable.

You could do all the movement using vectorsfrom the Mathutils module.

that is what I did Smoking :smiley:

I would not use the build in physics at all (as Smoking_mirror suggested). As you need a very simplified physics, you can calculate the position changes by your own.

Oh yes, I see that. :slight_smile:

own = bge.logic.getCurrentController().owner
FIXED_SPEED = 20.0
own.worldLinearVelocity.x = 0.0
own.worldLinearVelocity.magnitude = FIXED_SPEED

:stuck_out_tongue:

Can I change the “FIXED_SPEED” the same way as a property? In-case I want to add a speed power-up, or something.

Sure, If you want to use a property to control the speed just use:

own.worldLinearVelocity.magnitude =own['fixed_speed']

BTW: Most of the suggestions here require making a script that runs every pulse. That’s about 60 times per second.
So instead of defining the initial conditions and then letting Blender Physics carry on from there, the alternative is to make a script that models (simply) the movement of the ball every frame. 60 times a second you will nudge the ball in just the right direction. Usually it’s not a good idea to make a game mechanic like that in blender, but in a game like breakout, where only the ball, bat and blocks are moving there’s not going to be a lot to calculate.