Skip to content

Fix isPedOnGround#4317

Merged
Dutchman101 merged 7 commits into
multitheftauto:masterfrom
FileEX:bugfix/isPedOnGround
Aug 12, 2025
Merged

Fix isPedOnGround#4317
Dutchman101 merged 7 commits into
multitheftauto:masterfrom
FileEX:bugfix/isPedOnGround

Conversation

@FileEX

@FileEX FileEX commented Jul 28, 2025

Copy link
Copy Markdown
Member

Fixed #534

Original author: #1603

In addition to fixing the precision of IsOnGround, this PR adds a checkVehicles argument that allows specifying whether the function should return true if the ped is standing on a vehicle (by default it returns false, as before).

Comment thread Shared/mods/deathmatch/logic/Utils.cpp
Comment thread Shared/mods/deathmatch/logic/Utils.h Outdated
Comment thread Shared/mods/deathmatch/logic/Utils.cpp Outdated
Comment thread Shared/mods/deathmatch/logic/Utils.h Outdated
@ArranTuna

Copy link
Copy Markdown
Collaborator

I have tested this PR and confirms it fixes isPedOnGround being unreliable, when you were moving on a slope isPedOnGround would flicker between true/false now it stays on true.

This might not seem like an important fix, but it might be the reason why there is significant player movement desync where players can be seen moving forwards and then snapping back when the next puresync packet arrives because IsOnGround is used in puresync so if 1 puresync update sends you as not on ground it can cause this: "they’re flagged as airborne. While flagged airborne, puresync enables velocity-based prediction with little or no friction, so the remote player keeps sliding forward even after their real movement stops"

This desync is brought up a lot by players, so if this does fix it, they'd be very happy. And at the very least it'd fix this function which is also itself quite a useful fix.

@Dutchman101

Copy link
Copy Markdown
Member

Nice, this will likely be backported to the next 1.6.0 build that'll also be circulated, so it can be of use before the release of 1.7

@Dutchman101 Dutchman101 merged commit 257f4cd into multitheftauto:master Aug 12, 2025
7 checks passed
MTABot pushed a commit that referenced this pull request Aug 12, 2025
257f4cd Fix isPedOnGround (#4317)
88ca35e Update client en_US pot
@FileEX FileEX mentioned this pull request Mar 3, 2026
2 tasks
qaisjp pushed a commit that referenced this pull request Mar 8, 2026
#### Summary
This PR fixes the isVehicleOnGround function similarly to how #4317
fixed IsPedOnGround.

The current logic is very primitive. It simply checks the distance from
the bottom of the bounding box to the ground. That’s why if a vehicle
is, for example, lying on its roof, it returns false. It can also return
false on slopes, and for a Monster Truck it always returns false,
because its wheels aren’t included in the bounding box, which ends at
the model’s edge.
<img width="936" height="554" alt="image"
src="https://github.com/user-attachments/assets/e8d5fd41-1afa-42f1-b72e-fd2c715fba46"
/>

The fixed isVehicleOnGround function now first does a simple check to
see if any wheel is touching the ground. If so, the vehicle is
considered on the ground. If not, it performs a basic OOB check and
measures the distance to the ground. During testing, I never received a
false negative.

#### Motivation
Fixed #471 and #2093


#### Test plan
Tested.
```
Spawn Monster Truck
crun isVehicleOnGround(me.vehicle) -- always false
```

```
Spawn Beagle
crun setVehicleDamageProof(me.vehicle, true)
crun me.vehicle.rotation = Vector3(0, 180, 0)
crun isVehicleOnGround(me.vehicle) -- false
```

```
Spawn some car
crun setVehicleHandling(me.vehicle, 'suspensionLowerLimit', -1)
crun isVehicleOnGround(me.vehicle) -- false
```


#### Checklist

* [x] Your code should follow the [coding
guidelines](https://wiki.multitheftauto.com/index.php?title=Coding_guidelines).
* [x] Smaller pull requests are easier to review. If your pull request
is beefy, your pull request should be reviewable commit-by-commit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

isPedOnGround issues

5 participants