I’ve only been researching how to do this for about a day but I can’t seem to find a way to do it. The only way I successfully got it to curve was by using bezier curves, however, the ball moves too slowly and is kind of twitchy.
It looks pretty stable there but in the batter view its the loop seems to stutter, Is there any way yall would go about making a pitch script? to add curveballs, or knuckle balls and all that stuff if there is another way. If not then just making the ball travel smoother?
For throwing and catching, I used the Projectile Physics tutorial by Suphi Kaner which uses ApplyImpulse, however, when it comes to pitching it goes too fast since its a short distance and I also need it to curve depending on the pitch that is thrown. If yall could help me come up with any ideas on how to go about pitching, it would be very appreciated! I also got the bezier Idea from this post How to create a system where a ball curves from the left or right
If I didnt include something I was supposed to include in this post please let me know or if its in the wrong category since its my first post!
To fix the stuttering issue from the batter’s perspective, you can just move a copy of the baseball on the pitcher’s client. Of course, you’ll have to go through all the necessary validation techniques and whatnot to ensure that the ball the batter hits behaves similarly to the one that is actually present.
I would Recommend using RunService.Heartbeat when trying to interpolate something, it may make it smoother, something like this:
local alpha = 0 -- starting position
repeat
local deltaTime = RunService.Heartbeat:Wait() -- yields, and returns deltaTime
local current = math.min(1, alpha + (deltaTime/duration)) -- 1 is the limit, the second number is the current time
-- dt/dur should have it go based on the duration you have
-- code here to maybe have it run accordingly with this code
until alpha == 1 -- code breaks when alpha is exactly one
Its not that simple, plus without it you are able to properly control it.
FireClient and FireAllClients fire from the Server to Client (the code is on the Client), it makes it much easier to Replicate things, and to avoid latency.
Because TweenService will not follow the exact same way and Instead it will go straight to the position making it just a straight line, Creating a Multiple Tweens for one Purpose is not a good thing either.
So what would be the duration, just how much time I want the ball to take to get there? I tried using the code but I am pretty sure i am not implementing it the right way, my bad
As for using Tweens, I did find a module but It would stutter following along the curve aswell. I think heartbeat is the way to go