Skip to content

Commit fdf7e1a

Browse files
authored
Merge pull request #10392 from tetrapod00/interpolation-improve
Improve Physics Interpolation pages
2 parents 84c73e6 + f8f683c commit fdf7e1a

File tree

6 files changed

+28
-20
lines changed

6 files changed

+28
-20
lines changed

tutorials/physics/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ Physics
2020
collision_shapes_2d
2121
collision_shapes_3d
2222
large_world_coordinates
23-
troubleshooting_physics_issues
2423
interpolation/index
24+
troubleshooting_physics_issues

tutorials/physics/interpolation/2d_and_3d_physics_interpolation.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ Global versus local interpolation
1717
This has some implications:
1818

1919
- In 3D, it is easy to turn interpolation on and off at the level of each ``Node``,
20-
via the ``physics_interpolation_mode`` property in the Inspector, which can be
21-
set to ``On``, ``Off``, or ``Inherited``.
20+
via the :ref:`physics_interpolation_mode<class_Node_property_physics_interpolation_mode>`
21+
property in the Inspector, which can be set to ``On``, ``Off``, or ``Inherited``.
2222

2323
.. figure:: img/physics_interpolation_mode.webp
2424
:align: center
@@ -28,7 +28,7 @@ This has some implications:
2828
physics tick. In most cases this will not matter, but in some situations the
2929
interpolation can look slightly wrong.
3030
- In 2D, interpolated local transforms are passed down to children during
31-
rendering. This means that if a parent is set to ``physics_interpolation_mode``
31+
rendering. This means that if a parent has ``physics_interpolation_mode`` set to
3232
``On``, but the child is set to ``Off``, the child will still be interpolated if
3333
the parent is moving. *Only the child's local transform is uninterpolated.*
3434
Controlling the on / off behavior of 2D nodes therefore requires a little more
@@ -64,6 +64,6 @@ recommended to convert to ``CPUParticles2D`` (but keep a backup of your
6464
Other
6565
-----
6666

67-
- ``get_global_transform_interpolated()`` - this is currently only available for 3D.
68-
- ``MultiMeshes`` - these should be supported in both 2D and 3D.
67+
- ``get_global_transform_interpolated()`` is currently only available for 3D.
68+
- ``MultiMeshes`` are supported in both 2D and 3D.
6969

tutorials/physics/interpolation/advanced_physics_interpolation.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ What we really want to focus the camera on, is not the position of the target on
7676
the physics tick, but the *interpolated* position, i.e. the position at which the
7777
target will be rendered.
7878

79-
We can do this using the :ref:`Spatial.get_global_transform_interpolated<class_Node3D_method_get_global_transform_interpolated>`
80-
function. This acts exactly like getting :ref:`Spatial.global_transform<class_Node3D_property_global_transform>`
79+
We can do this using the :ref:`Node3D.get_global_transform_interpolated<class_Node3D_method_get_global_transform_interpolated>`
80+
function. This acts exactly like getting :ref:`Node3D.global_transform<class_Node3D_property_global_transform>`
8181
but it gives you the *interpolated* transform (during a ``_process()`` call).
8282

8383
.. important:: ``get_global_transform_interpolated()`` should only be used once or
@@ -142,8 +142,12 @@ and directly apply the mouse input to the camera rotation, rather than apply it
142142
Sometimes, especially with cameras, you will want to use a combination of
143143
interpolation and non-interpolation:
144144

145-
* A first person camera may position the camera at a player location (perhaps using :ref:`Spatial.get_global_transform_interpolated<class_Node3D_method_get_global_transform_interpolated>`), but control the Camera rotation from mouse look *without* interpolation.
146-
* A third person camera may similarly determine the look at (target location) of the camera using :ref:`Spatial.get_global_transform_interpolated<class_Node3D_method_get_global_transform_interpolated>`, but position the camera using mouse look *without* interpolation.
145+
- A first person camera may position the camera at a player location (perhaps using
146+
:ref:`Node3D.get_global_transform_interpolated<class_Node3D_method_get_global_transform_interpolated>`),
147+
but control the Camera rotation from mouse look *without* interpolation.
148+
- A third person camera may similarly determine the look at (target location) of the camera using
149+
:ref:`Node3D.get_global_transform_interpolated<class_Node3D_method_get_global_transform_interpolated>`,
150+
but position the camera using mouse look *without* interpolation.
147151

148152
There are many permutations and variations of camera types, but it should be clear
149153
that in many cases, disabling automatic physics interpolation and handling this

tutorials/physics/interpolation/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:allow_comments: False
2+
13
.. _doc_physics_interpolation:
24

35
Physics Interpolation

tutorials/physics/interpolation/physics_interpolation_introduction.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Introduction
44
============
55

66
Physics ticks and rendered frames
7-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7+
---------------------------------
88

99
One key concept to understand in Godot is the distinction between physics ticks
1010
(sometimes referred to as iterations or physics frames), and rendered frames. The

tutorials/physics/interpolation/using_physics_interpolation.rst

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ games will work with few changes. That said there are some situations which requ
1111
special treatment, and these will be described.
1212

1313
Turn on the physics interpolation setting
14-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
-----------------------------------------
1515

16-
The first step is to turn on physics interpolation in :ref:`ProjectSettings.physics/common/physics_interpolation<class_ProjectSettings_property_physics/common/physics_interpolation>`.
16+
The first step is to turn on physics interpolation in
17+
:ref:`Project Settings > Physics > Common > Physics Interpolation<class_ProjectSettings_property_physics/common/physics_interpolation>`
1718
You can now run your game.
1819

1920
It is likely that nothing looks hugely different, particularly if you are running
@@ -23,11 +24,12 @@ behind the scenes.
2324
.. tip::
2425

2526
To convert an existing game to use interpolation, it is highly recommended that
26-
you temporarily set :ref:`ProjectSettings.physics/common/physics_ticks_per_second<class_ProjectSettings_property_physics/common/physics_ticks_per_second>`
27-
to a low value such as 10, which will make interpolation problems more obvious.
27+
you temporarily set
28+
:ref:`Project Settings > Physics > Common > Physics Tick per Second<class_ProjectSettings_property_physics/common/physics_ticks_per_second>`
29+
to a low value such as ``10``, which will make interpolation problems more obvious.
2830

2931
Move (almost) all game logic from _process to _physics_process
30-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
32+
--------------------------------------------------------------
3133

3234
The most fundamental requirement for physics interpolation (which you may be doing
3335
already) is that you should be moving and performing game logic on your objects
@@ -57,9 +59,9 @@ longer run on every rendered frame.
5759

5860

5961
Ensure that all indirect movement happens during physics ticks
60-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
62+
--------------------------------------------------------------
6163

62-
Consider that in Godot, Nodes can be moved not just directly in your own scripts,
64+
Consider that in Godot, nodes can be moved not just directly in your own scripts,
6365
but also by automatic methods such as tweening, animation, and navigation. All
6466
these methods should also have their timing set to operate on the physics tick
6567
rather than each frame ("idle"), **if** you are using them to move objects (*these
@@ -70,7 +72,7 @@ methods can also be used to control properties that are not interpolated*).
7072
movement of parents should therefore also only occur during physics ticks.
7173

7274
Choose a physics tick rate
73-
^^^^^^^^^^^^^^^^^^^^^^^^^^
75+
--------------------------
7476

7577
When using physics interpolation, the rendering is decoupled from physics, and you
7678
can choose any value that makes sense for your game. You are no longer limited to
@@ -91,7 +93,7 @@ As a rough guide:
9193
changing the project setting.
9294

9395
Call ``reset_physics_interpolation()`` when teleporting objects
94-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
96+
---------------------------------------------------------------
9597

9698
Most of the time, interpolation is what you want between two physics ticks.
9799
However, there is one situation in which it may *not* be what you want. That is

0 commit comments

Comments
 (0)