-
-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
TimestepMode::Interpolated + TransformInterpolation does not function correctly #341
Comments
Also facing this issue. |
If your code change fixes this, could this be a PR? |
Merged
@sebcrozet I think #384 closed this. |
seems fixed indeed, updated repro code
use bevy::{prelude::*, sprite::MaterialMesh2dBundle};
use bevy_rapier2d::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.insert_resource(RapierConfiguration {
// gravity: Vec2::ZERO,
timestep_mode: TimestepMode::Interpolated {
dt: 1.0 / 5.0,
time_scale: 1.0,
substeps: 1,
},
..RapierConfiguration::new(100f32)
})
.add_plugins(RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0))
.add_plugins(RapierDebugRenderPlugin::default())
.add_systems(Startup, setup_graphics)
.add_systems(Startup, setup_physics)
.run();
}
fn setup_graphics(mut commands: Commands) {
// Add a camera so we can see the debug-render.
commands.spawn(Camera2dBundle::default());
}
fn setup_physics(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<ColorMaterial>>,
) {
/* Create the ground. */
commands
.spawn(Collider::cuboid(500.0, 50.0))
.insert(TransformBundle::from(Transform::from_xyz(0.0, -100.0, 0.0)));
/* Create the bouncing ball with TransformInterpolation. */
commands
.spawn(RigidBody::Dynamic)
.insert(Collider::ball(50.0))
.insert(Restitution::coefficient(0.7))
.insert(TransformInterpolation::default())
.insert(MaterialMesh2dBundle {
mesh: meshes.add(Circle::new(50.)).into(),
material: materials.add(ColorMaterial::from(Color::BLUE)),
transform: Transform::from_xyz(0.0, 400.0, 0.0),
..default()
});
/* Create the bouncing ball without TransformInterpolation. */
commands
.spawn(RigidBody::Dynamic)
.insert(Collider::ball(50.0))
.insert(Restitution::coefficient(0.7))
.insert(MaterialMesh2dBundle {
mesh: meshes.add(Circle::new(50.)).into(),
material: materials.add(ColorMaterial::from(Color::GREEN)),
transform: Transform::from_xyz(100.0, 400.0, 0.0),
..default()
});
} interpolation_ok.mp4 |
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Currently using TimestepMode::Interpolated with TransformInterpolation does not result in interpolated transforms
It appears this issue is caused by
src\plugin\systems.rs:332
whereinterpolation.start
andinterpolation.end
are set toNone
without checking whethertransform_changed
returnstrue
Updating the code to first check if the transform has changed results in the expected interpolated behavior
See minimal reproducible example
The text was updated successfully, but these errors were encountered: