Using the code below, I almost have it going, but not quite. The pads have a manually fitted polygon-collider, matching the bend on it.The ball has a circle collider, which is not a trigger.I always have the following variables available: current width in units, standard width in units, and current scale as a float. The effect of “Point 1” is the blue arrow, and the end-result implementing the functionality of both “Point 1” and “Point 2”, is the green arrow. On the image below, the red arrow is the velocity vector of the ball. (NOTE: The speed of the ball after the bounce is handled later!) The natural wall-bounce of the ball, should be taken into account, so the resulting bounce vector, will be a product of the normalized velocity vector of the ball, and the calculated and normalized directional vector from the normal wall/pad-bounce (see “Point 1”).Depending on where the ball hits the paddle, it should bounce off in an angle of between -90 and 90 degrees, where the middle of the pad would give 0 degrees, and the extremities on each side should give -90 or 90 respectively.The pads are going to appear in various rotations, and therefore the physics for bouncing the balls off the pads, have to be vector-based.ĮDIT: I’ve answered my own question (see below this post). I’m making a 2D game with pads and balls, sort of like Pong, in Unity 4.6.1.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |