Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

Troubleshooting physics issues

При работе с физическим движком вы можете столкнуться с неожиданными результатами.

While many of these issues can be resolved through configuration, some of them are the result of engine bugs. For known issues related to the physics engine, see open physics-related issues on GitHub. Looking through closed issues can also help answer questions related to physics engine behavior.

Объекты проходят друг через друга на высоких скоростях

This is known as tunneling. Enabling Continuous CD in the RigidBody properties can sometimes resolve this issue. If this does not help, there are other solutions you can try:

  • Make your static collision shapes thicker. For example, if you have a thin floor that the player can't get below in some way, you can make the collider thicker than the floor's visual representation.

  • Modify your fast-moving object's collision shape depending on its movement speed. The faster the object moves, the larger the collision shape should extend outside of the object to ensure it can collide with thin walls more reliably.

  • Increase Physics Ticks Per Second in the advanced Project Settings. While this has other benefits (such as more stable simulation and reduced input lag), this increases CPU utilization and may not be viable for mobile/web platforms. Multipliers of the default value of 60 (such as 120, 180 or 240) should be preferred for a smooth appearance on most displays.

Stacked objects are unstable and wobbly

Despite seeming like a simple problem, stable RigidBody simulation with stacked objects is difficult to implement in a physics engine. This is caused by integrating forces going against each other. The more stacked objects are present, the stronger the forces will be against each other. This eventually causes the simulation to become wobbly, making the objects unable to rest on top of each other without moving.

Increasing the physics simulation rate can help alleviate this issue. To do so, increase Physics Ticks Per Second in the advanced Project Settings. Note that increases CPU utilization and may not be viable for mobile/web platforms. Multipliers of the default value of 60 (such as 120, 180 or 240) should be preferred for a smooth appearance on most displays.

Масштабированные физические тела или формы столкновений не сталкиваются правильно

Godot does not currently support scaling of physics bodies or collision shapes. As a workaround, change the collision shape's extents instead of changing its scale. If you want the visual representation's scale to change as well, change the scale of the underlying visual representation (Sprite2D, MeshInstance3D, …) and change the collision shape's extents separately. Make sure the collision shape is not a child of the visual representation in this case.

Since resources are shared by default, you'll have to make the collision shape resource unique if you don't want the change to be applied to all nodes using the same collision shape resource in the scene. This can be done by calling duplicate() in a script on the collision shape resource before changing its size.

Тонкие предметы шатаются, когда лежат на полу

This can be due to one of two causes:

  • Форма столкновения пола слишком тонкая.

  • Форма столкновения RigidBody's слишком тонкая.

В первом случае это можно облегчить, сделав форму столкновения пола толще. Например, если у вас тонкий пол, ниже которого игрок каким-то образом не может пройти, вы можете сделать коллайдер толще, чем визуальное представление пола.

Во втором случае эту проблему обычно можно решить только увеличением скорости физического моделирования (поскольку увеличение толщины формы приведет к разрыву между визуальным представлением RigidBody's и его столкновением).

In both cases, increasing the physics simulation rate can also help alleviate this issue. To do so, increase Physics Ticks Per Second in the advanced Project Settings. Note that this increases CPU utilization and may not be viable for mobile/web platforms. Multipliers of the default value of 60 (such as 120, 180 or 240) should be preferred for a smooth appearance on most displays.

Cylinder collision shapes are unstable

При переходе от Bullet к GodotPhysics в Godot 4 формы столкновений цилиндров пришлось переопределять с нуля. Однако формы столкновений цилиндров — одна из самых сложных для поддержки форм, поэтому многие другие физические движки не предоставляют для них никакой поддержки. В настоящее время известно несколько ошибок с формами столкновения цилиндров.

На данный момент мы рекомендуем использовать для персонажей формы столкновения коробок или капсул. Коробки обычно обеспечивают лучшую надежность, но имеют недостаток: персонажу требуется больше места по диагонали. Формы столкновения капсул не имеют этого недостатка, но их форма может затруднить точный платформер.

Симуляция VehicleBody нестабильна, особенно на высоких скоростях

When a physics body moves at a high speed, it travels a large distance between each physics step. For instance, when using the 1 unit = 1 meter convention in 3D, a vehicle moving at 360 km/h will travel 100 units per second. With the default physics simulation rate of 60 Hz, the vehicle moves by ~1.67 units each physics tick. This means that small objects may be ignored entirely by the vehicle (due to tunneling), but also that the simulation has little data to work with in general at such a high speed.

Fast-moving vehicles can benefit a lot from an increased physics simulation rate. To do so, increase Physics Ticks Per Second in the advanced Project Settings. Note that this increases CPU utilization and may not be viable for mobile/web platforms. Multipliers of the default value of 60 (such as 120, 180 or 240) should be preferred for a smooth appearance on most displays.

Столкновение приводит к ударам, когда объект движется по тайлам

Это известная проблема физического движка, возникающая из-за того, что объект ударяется о края фигуры, даже если этот край закрыт другой фигурой. Это может происходить как в 2D, так и в 3D.

Лучший способ обойти эту проблему — создать «составной» коллайдер. Это означает, что вместо столкновения отдельных плиток вы создаете единую форму столкновения, представляющую столкновение для группы плиток. Как правило, вам следует разделять составные коллайдеры по каждому острову (это означает, что каждая группа соприкасающихся тайлов получает свой собственный коллайдер).

Использование составного коллайдера также может в некоторых случаях повысить производительность физического анализа. Однако, поскольку составная форма реализуется гораздо сложнее, она не во всех случаях может принести чистый выигрыш в производительности.

Частота кадров падает, когда объект касается другого объекта

Вероятно, это связано с тем, что один из объектов использует слишком сложную форму столкновения. Выпуклые формы столкновений должны использовать как можно меньшее количество фигур из соображений производительности. Полагаясь на автоматическую генерацию Godot, возможно, вы получите десятки, если не сотни фигур, созданных для одного ресурса столкновения выпуклых форм.

В некоторых случаях замена выпуклого коллайдера парой примитивных форм столкновения (коробка, сфера или капсула) может обеспечить лучшую производительность.

This issue can also occur with StaticBodies that use very detailed trimesh (concave) collisions. In this case, use a simplified representation of the level geometry as a collider. Not only this will improve physics simulation performance significantly, but this can also improve stability by letting you remove small fixtures and crevices from being considered by collision.

Физическое моделирование ненадежно, когда оно находится далеко от начала координат мира

This is caused by floating-point precision errors, which become more pronounced as the physics simulation occurs further away from the world origin. This issue also affects rendering, which results in wobbly camera movement when far away from the world origin. See Large world coordinates for more information.