# How to launch a soccer ball on a parabolic path in a 2.5D game?

I am trying to make simple 2D soccer game in Unity, but I feel a top-down view in such simple games isn't as exciting as the pseudo-3D view in games like Kunio Kun Nekketsu Soccer League.

I am trying to understand how to implement a similar pseudo-3D effect:

1. The players move along the x (left and right) and y axis (the upper and lower part of the field), but they can jump in z axis.

2. The kicked ball moves in the x, y axis (because it opposes the force of gravity), but also z, when, for example, we pass from one wing to the other.

How can all this be mathematically realized in a 2D game? A ball kicked in a platform game would only move in a parabola on the x and y axes, but here there's a z axis and things get complicated.

Moreover, look at the second picture. The goal line is at a slight angle to the Z axis (so the Y axis is in fact at a slight angle to the Z axis). But, in the second picture you can see that in the middle part of the pitch, the Y and Z axes are parallel to each other.

• Can you actually interact/ intercept with the ball while it is flying? And I guess they used the distorted first image to actually add some perpective, else the goal would just look like a white line May 6, 2023 at 19:04
• The way the y axis shows a perspective-adjusted lean at the goal line suggests to me that this game is actually tracking positions in 3D, then using a projection matrix to convert those 3D points to 2D screen positions to draw the sprites. But you can also calculate a parabolic arc for a 2.5D projectile as shown here. May 6, 2023 at 20:43

If I were to do this, I would seperate the problem into 2 parts:

Visual part : when the ball is kicked (just a rigidbody2D.AddForce) to mid-air, turn on the shadow prefab of the ball (just a black version of the sprite and elongated to look like a shadow). During the trajectory movement of the ball, the shadow copy and uses the x pos value of the ball, while y pos remain unchanged.

Physic Interaction: In your Ball script, create a float zHeight to mimic the height movement if it were on a z axis. Like this : . Then you use the zHeight value to control and affect any physic interaction and sorting order. For example, when the zHeight is over a half the length of the character sprite height (meaning its above waist) turn off the the interaction by setting it to airborne layer (use layer cuz you can't turn off rigidbody during the trajectory unless you want to write your own projectile code), and then set it back to ground layer when zHeight falls below waist. Note that:

zHeight = Ball.transform.position.y - yOffset;


And yOffset is the y position when the ball is kicked.