I’ve been able to generate paths using PathFindingService for the ball to follow, but I can’t think of any way to actually make the ball follow the path.
I have tried using a VectorForce towards the direction of a waypoint and estimating that it will reach the waypoint, but this is obviously inconsistent and quickly begins to bug out.
Also disabling AgentCanJump breaks pathfinding becase the ball tries to jump on itself which it cant do.
So I need your guys’ help. How in Robloxia can I make a ball follow a path created by PathFindingService. I am truly stumped.
A very important detail is that I need the ball to ROLL, not just slide
He has been using ChatGPT for the past 20 mins and keeps denying it. Anything he sends, do not use it. He got upset earlier because I took his solution not using ChatGPT
This will probably need a lot of custom-made code if you want it to look realistic, if you want the ball to roll like it’s not being acted upon by a script, you’re most likely going to need to make your own module to find the proper force to put on the ball in realtime and create a path to the next node, and pathfindingservice simply doesn’t do that.
Alternatively, you can try to put an angularvelocity on the ball while tweening its position with tweenservice so that it can rotate in midair, and find the angle that it should be turning based on the direction and angle between point A and point B.
Physics isn’t my cup of tea so I don’t know exactly how you would do this, but I hope you’re able to get a proper solution from someone who knows more about this concept than me.
After dwelling on it. I think my main problem is detecting when the ball reaches the desired waypoint. I have everything else set up, but I can’t figure out a resource efficient way to have something akin to Humanoid.MoveToFinished.
I suppose you could check if the position of the ball is within a certain magnitude from the destination waypoint, depending on if you’re using tweenservice, you can check for when the tween ends.
I’m using a VectorVelocity to roll it in the direction of a waypoint, and I don’t want to just poll every X seconds for the distance from said waypoint, because that can quickly use up a lot of resouces.
That makes perfect sense, you might try using .Touched on the ball and have an invisible trigger set to the size of the ball at the waypoint position, but I’m not sure if it’ll work 100% of the time or be what you’re looking for.
Bezier curves might look good for making sure corners are soft, but would require extra clearance when computing the path, because it does not follow the path exactly. Also you would want to consider if it is good or bad that the ball moves quicker in the middle of the bezier path. If you space the path waypoints differently, you could affect how tight it will go around corners.
I am not sure if you can get the ball to roll with an AlignPosition constraint, but my guess is you can, if you set the friction of the ball. You want to make sure the constraint does not have enough force to lift the ball, but does have enough force to make it roll.
Would be fun to see a ball following a path as if by magic - I hope you get something working.