How to curve a soccer ball?

Heyo! We’ve recently been trying to smoothen out the soccer ball mechanics for our game, Roblox Football Club.

We’ve gotten client-server ball replication, basic dribbling & shooting however we do miss one of the biggest fundamentals: ball curving.

The idea we came down to is to record your mouse’s position while holding the left mouse button (you hold the mouse button to shoot) & translate that to the ball, however we have no idea of how to implement this:

  • How would we go about translating a 2d position in a 3d environment?
  • How do we override/change the velocity of the ball so it curves?
  • How do you determine the power of the curve?

Other games in our genre have simply just added the ability to select your left foot/right foot mechanic and always have a SET curve velocity depending on which foot you choose (to go left or right) however I feel like that is very limiting and doesn’t give much control for the player

Here’s a video of our current gameplay so you have a better glimpse of what we’ve done so far:

To provide the actual curve effect, you have 2 options you could do to achieve this. Either;

Apply a bodyforce to the ball in the direction of your curve whenever you want to curve the ball for a set period of time and it’ll curve smoothly with some tweaking.

Or

Have a bodyforce permanently inside the ball which determines the new curve every frame using the magnus equation (cross product of ball’s velocity and spin) and then apply a spin to the ball whenever you want to curve the ball perpendicular to the curve direction (for example if you wanted to curve the ball right or left then you would apply spin on the Y axis.

Option 1 is much simpler while option 2 would need much more tweaking and time to get right but the end product will have more dynamic and smooth curve.

To determine the curve’s direction using the mouse I would find the screen’s centre (use Vector2.new(ViewportFrame.Size.X / 2, ViewportFrame.Size.Y / 2)) then check if the mouse position is to the left or right of that centre and then apply the curve accordingly.

To determine how strong the curve would be you could check how far to the sides the player’s mouse is by seeing how close the mouse is to the edge of the screen (do Vector2.new(ViewportFrame.Size.X, ViewportFrame.Size.Y / 2) to find the right edge of the screen) and then minus the X axis of the screen’s edge by the mouse’s X axis position to see how close the mouse is to the screen.

If there are any mistakes in this or you dont like the format then excuse me since im on mobile :sweat_smile:

If you have any other questions then dont hesitate to ask!