How to create a system where a ball curves from the left or right

I want to create a system where a ball goes forward on a curve, but instead of going up and down, I want it to go left and right. I know that this is possible with bezier curves, but I want collisions to still work while the ball is moving. How can I do this?

Example Video

Up and down movement is caused by gravity acceleration on (0,-1,0) and an initial upward velocity.

For left to right physics based just repeat it.

Initially a velocity leftwards like the characters -hrp.CFrame.RightVector to present the initial kick

and an acceleration force in the direction of hrp.CFrame.RightVector or rightwards to represent the spin causing the aerodynamics lift phenomenon thingy. Vector force or Bodyforce should do the same thing.

Be sure to remove the acceleration or slowly decrease it after a while to represent drag forces or air friction.

When you do this, the ball continues in one direction, it doesn’t curve.

Could you provide some sort of code sample?

This is most likely done by bezier curves this can help you

You can do that, but the ball won’t handle collision while on the curve.

This will just make the rotation you can make other physics for it (or roblox default physics) or use AngularVelocity

Could you provide a code sample?

Sorry I was gone for a bit, you can read about it on the website I provided, but i dont think it does curve tho…
It just gives it the physics

To curve the ball, you can try parenting an Align Position object to the ball,which pushes the ball towards a point (which you would have to calculate yourself; you could try raycasting intially, then changing the vector of the ball). This way, align position will push the ball midair, towards a point, creating a curve effect.

Make sure to destroy the AlignPosition object after you’re done using it, or it will continue to pull the ball towards the point.

image

this video will show you how to do it without the curve

to add a curve try to imagen it as having 2 gravity’s
the normal gravity pushing down
and the second gravity pushing to the right or left

you can use a VectorForce | Roblox Creator Documentation to add the second gravity and you would use the same formula in the video to add a counter force to make the ball hit the target position

2 Likes