wigglebone icon indicating copy to clipboard operation
wigglebone copied to clipboard

Incorrect velocity when physics tick rate is lower than rendering framerate

Open geegaz opened this issue 1 year ago • 1 comments

Godot version

v4.3.stable.official [77dcf97d8]

Issue description

A WiggleBone attached to a PhysicsBody3D or to a node that's moved with _physics_process() will move incorrectly if the physics tick rate is lower or not synced with the framerate. In this case, the WiggleBone will follow the velocity instead of reacting to acceleration (see #10)

This can be somewhat fixed by separating _process() and _physics_process() in wiggle_bone.gd, and providing a new parameter to process the WiggleBone in _physics_process() instead. However, this makes the effect slower/faster depending on the physics tick rate (see video)

https://github.com/user-attachments/assets/83def426-6d9f-4f76-8c9a-9e81220437fa

Repro project:

WiggleBone_MRP.zip

Steps to reproduce

  • Start a new Godot project
  • Import WiggleBone
  • Attach a WiggleBone to a CharacterBody3D with a minimal movement script
  • In the project settings, set "Physics ticks per second" to 30 (Physics > Common (advanced settings)) OR
  • In a script, set Engine.physics_ticks_per_second to 30
  • Notice the issue

geegaz avatar Sep 06 '24 18:09 geegaz

Since this is due to a desync between the physics and rendering, it can also be fixed by attaching a physics interpolation script like 8bit's godot recipe to the skeleton or a parent in the hierarchy before the PhysicsBody

geegaz avatar Sep 06 '24 18:09 geegaz

The latest release is a complete rewrite (see release notes) and adds new nodes which should not have any frame rate issues. I could not find a stable implementation for the previous behaviour which used the acceleration for movement. It now uses the velocity.

detomon avatar Nov 11 '24 12:11 detomon