Physics Interpolation - add helper warnings #60531
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When physics interpolation is active on a node, it is essential that transforms are updated during "_physics_process()" rather than "_process()" calls, for the interpolation to give the correct result.
This PR adds optional warnings for instances, cameras and multimeshes which can flag updates being incorrectly called, and thus make these problems much easier to fix.
The warnings only occur in DEBUG_ENABLED builds, and when physics interpolation is enabled, and can be switched on and off with project setting
debug/settings/physics_interpolation/enable_warnings
.For instances, it prints the node name in the warning. For cameras and multimeshes there is no name available, this is unlikely to be a problem with cameras (as there is normally only 1 or 2) and the warning for multimesh is better than none at all. There is no objectID stored per multimesh currently. It could be made to store this, but is probably overkill for this warning feature.
When the warning is issued, the usual step to take is to examine the object scripts etc and move anything being updated in
_process()
to_physics_process()
. Additionally some "magic" nodes (tweening etc) may move nodes automatically, these may similarly need to have their mode flipped to operate on physics tick rather than idle.The warning uses the wording "usually", and "possible benign", because it is not a problem to occasionally move nodes about in e.g.
_ready()
or teleported as a result of an event in_process()
. But usually when the warnings are showing a lot it will indicate a problem.Example output
Notes
project_settings
value are only done infrequently, so I'm not overly worried that these will create a performance issue at runtime. The alternative would be to cache the setting.