I’m writing classical Breakout/Arkanoid like game with 2D physics. Having setup colliders for block, paddle and ball everything seem to “work”. By “work” I mean that physics is too realistic causing movements of ball to be non arcade like in some occassions.
There are two different problems that may happen. Since ball is purely controlled by physics without gravity it’s possible to cause movement that is (almost) horizontal or vertical.
If you play original Breakout/Arkanoid you may observe that ball always bounces with angle big enough keeping ball moving in somewhat diagonal direction but never enters purely horizontal or vertical direction.
How I could achieve such an arcade movement? Realistic physics, as easy it was to setup, is not correct one for this kind of a game.
You can program all of this stuff yourself to get the exact “feel” for the game that you want.
Basically, just do not use Unity’s physics but still use the colliders.
Then track position and velocity for the ball and paddle in variables.
In your collision routines take into account where the ball lands on the paddle (can be done by comparing positions or using multiple colliders on the paddle) and the velocities of both the paddle and the ball. Adjust the ball velocity accordingly.
I don’t get into all of this physics stuff. I could understand it if we were developing a NASA simulation or perhaps a racing game and wanted to model reality. But these are games! They are meant to be fun not model reality. If you play something like Super Mario brothers they certainly do not use real physics for the game world. Just apply your own physics and make everything interact the way that feels right.
I suppose you could tweak around with the objects weights and the forces being applied and do it with physics but taking into account the time and effort spent doing that it just makes sense to me to manually program each interaction the way I want it to behave.
Well I got inspiration from that particular tutorial and it uses plain 2D physics that has exactly problems I describe. Physics simulation is too realistic to be usable in real game. Game Breakout type game is supposed to be fun and playable, not realistic…
You don’t need physics books unless you want to get right back to where you are with Unity physics. Just add a script to the ball (if you have none) and use variables xspd and yspd to store current velocity. If ball hits left edge of paddle then xspd -= greater amount. If ball hits right side xspd += greater amount. Where greater amount is more then if ball hits center of paddle. In all cases if ballyspd <0 ballyspd = -ballyspd. That is a start. Then can take into account velocity of paddle at time of impact.
Well it’s been like 20 years since I did anything game related I seem to forgot some basic things…
Now what kind of setup would be easiest to handle triggers to blocks that I’m trying to destroy or side/top wall? That’s what is probably something so simple that I’m trying it too complex way…