Cars That Hit and Be Hit

So, I know that for a player controlled vehicle to hit an object, the object has to be given ownership to the player that is hitting it.(Or else you get weird physic issues where the player dead stops on the part and the part seems anchored, and other weird things…)

Is it possible to have two player controlled cars that can hit each other, and create realistic movements? For example, like a pit maneuver, t-bone, and head-on? Currently the Roblox physics for car on car violence just winds up being really glitchy and weird.

Example.mp4
A league race highlight reel from a week ago.

3 Likes

I don’t think it’s possible. Not even GTA V Online is as stable as you think, because I’ve had experiences in it where some guy comes out of nowhere and hits the side of my car and we both end up stopping abruptly.

1 Like

I mean, it won’t be perfect all the time but I’d like to atleast attempt to make it work a little nicer than the current. Basically the big issue right now is Roblox having “lag vision.” Or atleast that’s what the Roblox community is calling it, where, for example:

User A is driving a car.
User B is driving another car.
User C is standing still, observing both cars.

User C sees both Car A and Car B side by side, door to door.
User A sees them self in front of Car B by 2 car lengths.
User B seems them self in front of Car A by 1 car length.

It’s really random, but basically, what a driver sees is never the same as a stationary user, and generally the stationary user’s view is accepted as the “correct” view for league racing and what not for positioning.

5 Likes

The problem is to have accurate collision both clients have to see into the future to compensate for the latency.
While you can extrapolate to a certain extend you will still get inaccurate results unless the cars are moving in a perfectly straight line/predictable way.
Though IIRC the physics engine doesn’t extrapolate moving objects anyway so you would have to do the physics yourself if you want any sort of extrapolation.

3 Likes

So like, I’m not exactly the smartest person in the world with the whole scripting your own physics kind of thing. But would trying to extrapolate collisions cause a lot of stress on the server/client? And, do you think it’d really be possible with Roblox with around 10 players or so in-game?

Possible? Probably, but not worth the effort it would take.

2 Likes

Making fast paced, accurate collision is very tricky due to latency.

The best you can do and should do is client side prediction.
This is where all cars are local to each client and each client replicates the position of each car by predicting their next position. There’s interesting papers online about this that vary in difficulty.

Integrating collisions into the prediction is not easy. You’ll have to tell the other client the force at which you hit them and the angle so they end up in similar positions on both clients.

3 Likes

As a developer, it’s a bit hilarious that since you understand the concept of client server latency, you can get something of an edge in something like a jailbreak chase, making your moves early and guessing the other user’s ping lol.

Something I’ve suggested before for cars is maintaining velocity based on ping. In GTA, if your internet drops out for a moment and someone is driving you, their car won’t stop, and rather will keep moving forward until it hits a wall. When the connection is restored, the vehicle pings back. On my subpar internet connection incapable of streaming, I find that to be a godsend.

3 Likes

You could use BodyMovers server side to simulate a crash, and then make the cars in different collision groups to stop the roblox physics engine doing anythig dumb.

2 Likes

What would you do with the cars on the clients while that happens?

What do you mean? Server changes replicate to the client.

Clients are driving the cars at each other at high speed. By the time the server detects a collision, the cars would have clipped through each other considerably on both clients.

Okay then you use BodyMovers on the client to simulate the crash on their screen and then update the position on the server as well so that the replication is as good as possible.

So separately calculate the collision on each client and the server and blend the two together as soon as the server data comes in?

1 Like

Perhaps more the collision is simulated on the client and then after the actual contact has happened the cars replicate their position so they’re the same on each other’s screens through the server.

1 Like

in some games, predicting player movements due to latency becomes a part of high-level play and an unintended game mechanic :slight_smile:

1 Like