Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

What are my reasonable options for creating realistic sports physics?

Asked by 4 years ago
Edited 4 years ago

I have begun developing a basketball game and have naturally found myself trying to think of ways to restrict the basketball's physics to produce realistic results (unlike the madness that ensues when a part is squished and fires a thousand studs away). My current idea includes updating the CFrame of the ball frequently to keep it along clean, trigonometric paths in the air and creating some pre-determined angles at which the ball can fly when motion is interrupted. Currently, I'm struggling to figure out a way around the inconsistencies caused by remote events and manipulation of network ownership to create a game that has as little delay as possible when the ball is transferred from a player's possession to the rest of the court. Any ideas and suggestions are encouraged.

For further clarification, my question is not primarily about modeling projectile motion. The main issue I have is the lag caused by remote events/switching network ownership, and I'm curious to know what other options there are for altering a brick's velocity upon some event fired by a player.

0
You need to do more research as well as provide code before posting here. There is a great tutorial on projectile motion right on this website (uses physics though): https://scriptinghelpers.org/guides/modeling-a-projectiles-motion PhantomVisual 992 — 4y
0
Well, what code do you want me to show? I'm looking for new ideas, not fixing a script. I've already concluded that the methods I'm currently aware of are insufficient, which is why I'm here. BlueGrovyle 278 — 4y
0
I mean you could be using the network ownership and/or physics wrong, who knows. You could predetermine the path the ball takes and send the information to each client to replicate it. There will always be a delay, you can either stick with it or make it smooth for one person. PhantomVisual 992 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

What you could do to reduce lag is to make each client (and the server to prevent people from hacking it to make it at the goal) calculate the paths the basketball is going to be at and each modify the basketball's CFrame to follow it. The server sends what position the basketball is at on its side and if a client's basketball is too far away from the server's position it readjusts it using a tween. When the client wants to move the ball, it should call the server with when the client called it (make sure to use UTC time, not tick and only use tick to get more precise timing below the seconds like tick() - math.floor(tick()) + seconds + minutes*60 and get seconds/minutes using os.date) and the server speeds up the ball by how much time elapsed (but you might want to make a max time it speeds up, like 0.5 second and if there's a 0.6 second difference from when the client called it, it only speeds it up like if there's a 0.5 second difference) to make up for the time difference.

This should prevents hackers from teleporting the ball to the goal since they don't have network ownership, and also makes it smoother by making each client calculate the movement themselves.

Ad

Answer this question