Hello.
I am making a game like BreakOut.
But I have a problem that I haven’t solved.
If there are no blocks to break, when I hit the ball with the paddle, it doesn’t change direction and just stays up and down, especially on mobile touch.
So I’ve tried using the events below, but it doesn’t fix it.
It also causes it to bounce back and forth between the left and right walls dozens of times.
Is there a workaround for this?
Event >
Apply force at a random angle if the ball’s angleForce is less than or equal to 20 degrees or greater than 160 degrees.
If the ball’s angleForce is 270 degrees, apply force at a random angle.
I have no idea what is going on there
Even better your issue makes no sense like there should be no way it happens since you are not checking anything against blocks
So WTF?
But here is breakout example
Maybe it can help you?
No matter how much I try to steer the ball sideways when I touch the paddle, it keeps going up 270 degrees (assuming there are no block in the way).
We asked for a solution to the same repetitive continuity of the ball’s movement with or without blocks in the path of the ball, and based on the game example you provided.
And now you will see exactly what each value is at the time
Where why you change in last event Y velocity?
Shouldn’t you be changing Y an X velocity and not only Y?
Again i have no idea if its right or wrong
Like i said i used physics only once
I am not sure if LinearVelocityAngle even shows angle of movement
But speed of movement
AGAIN I AM NOT SURE but the longer i look at it more i believe you are checking and affecting speed and not actual ball angle
I did the same thing as indicated in the sample game event, where the comment in the event said this was the reason.
Avoid the ball getting stuck. So, that it won’t go back and forth in the same direction. The physics engine doesn’t have an expression/condition to check the angle of the force of an object (Here, it is the ball). So, we use some maths to get the angle of movement from the velocity on each axis. The calculation returns a negative value for reflex angles (greater than 180). We can’t use negative angles as we need to calculate if the movement is -170 and 170 (190 and 170) that is > -170 and > 170, it won’t work. So, we use the absolute value of the angles to find the angle.
I would create new scene and try to copy events from example i sent in my 1st message
Then see after adding which it stops working and try to deduce the problem
Or maybe it would solve the problem
The ball is stuck between the block and the top of the wall, so it’s only doing vertical motion.
I’d show you a video, but I can’t embed it, so here’s an image.
The ball is trapped. The game cannot progress further. Both the block and the wall are static. I’m looking for a way to get the ball out in this case. So I wanted to use an event that would unconditionally change the angle of the ball when it travels 270 degrees (-90 degrees). But it doesn’t work. If the block and the wall collide twice at the same angle (270 degrees), what event could force the ball to change direction?
BUT are you 100% sure you are checking right value?
I would put it to text object to see what is actual vertical position
AND you could
A way to fix this would be to check if ball X position
For example store its X position information into variable called BallXPos
And check how many times ball hit wall or other block
Like each time ball hit wall or block you add 1 to variable
Let’s call this variable HitCount
Now
3 things
1 - You check if BallXPos is +/- 10 for example
Condition
Variable BallXPos is less than Ball.X()-10
Variable BallXPos is greater than Ball.X()+10
Action
Change Variabe BallXPos set to Ball.X()
Change variable HitCount SET TO 0
2 - You actually count ball hits
Condition
Ball is in collision with block
Trigger once
Action
Change variable HitCount ADD 1
3 - Last event
Condition
Variable BallXPos is less than Ball.X()-10
Variable BallXPos is greater than Ball.X()+10
Variable HitCount is greater than 6
Action
And here you add some impuls to your ball in some horizontal angle
And so if position of ball changed more than 10 pixels to the left or right
NEW X position of ball will be saved to variable
And HitCount variable will be set to 0
IF ball keep colliding with blocks more than 6 times while its X position will not go up or down for 10 pixels (meaning it is stuck in situation you describe)
Then you add force/impuls or whatever to give it push in some horizontal angle
Have nothing to do with it
That is why it is not working for you
Now i have idea
Can you just rotate your ball to the angle it is flying?
And if ball angle is -90° or 90°
You would then simply add some push in different angle?
Or like just actually use this acrtion