0
\$\begingroup\$

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.

Screenshot of 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.

Screenshot at the center of the field

\$\endgroup\$
2
  • \$\begingroup\$ 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 \$\endgroup\$
    – Zibelas
    May 6, 2023 at 19:04
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – DMGregory
    May 6, 2023 at 20:43

1 Answer 1

0
\$\begingroup\$

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 : Image. 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.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .