2D physics interpolation #2091
Replies: 2 comments 1 reply
-
Look at cpp-tests |
Beta Was this translation helpful? Give feedback.
-
it's pretty simple, when you set any object position to the physics engine's position you have to keep track of the last delta time, typically in a fixed physics update it would be 60 frames a second, which is 0.0166666666666667 delta you then store a variable then you map the value from kinda like this lastDt is Vec2 PhysicsWorld::getInterpolatedDynamicPosition(DynamicShape* s)
{
float x = Math::map(accumPhysicsDt, 0.0f, lastDt, s->iox, s->x);
float y = Math::map(accumPhysicsDt, 0.0f, lastDt, s->ioy, s->y);
return Vec2(x, y);
} you could implement it in a way where you store the future position but then you have to fiddle around with velocity and stuff that are so confusing, with this technique you have 1 frame delay because of the old position and it depends whether it's fine or not, with higher physics updates the issue becomes less of a worry. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
In latest Godot they announce "2D physics interpolation":
https://godotengine.org/releases/4.3/#highlights-2d-physics-interpolation
physics-interpolation-2d.webm
How we can do the same in Axmol?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions