Skip to content

Fix isVehicleOnGround#4738

Open
FileEX wants to merge 2 commits intomultitheftauto:masterfrom
FileEX:bugfix/isVehicleOnGround
Open

Fix isVehicleOnGround#4738
FileEX wants to merge 2 commits intomultitheftauto:masterfrom
FileEX:bugfix/isVehicleOnGround

Conversation

@FileEX
Copy link
Member

@FileEX FileEX commented Mar 3, 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.
image

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

  • Your code should follow the coding guidelines.
  • Smaller pull requests are easier to review. If your pull request is beefy, your pull request should be reviewable commit-by-commit.

@FileEX FileEX requested a review from a team as a code owner March 3, 2026 18:04
@FileEX FileEX linked an issue Mar 3, 2026 that may be closed by this pull request
@FileEX FileEX added the bugfix Solution to a bug of any kind label Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Solution to a bug of any kind

Projects

None yet

Development

Successfully merging this pull request may close these issues.

isVehicleOnGround does not work after setVehicleHandling isVehicleOnGround sometimes returns false incorrectly

1 participant