-
I'm trying to use For context, I'm building a multiplayer game server that runs multiple minimal versions of Bevy, with the bevy_rapier plugin and the TimePlugin. I'm manually ticking each Bevy app, since I'm running multiple bevy apps on the same time. I've configured the TimePlugin to use the Here's the code I used to configure the TimePlugin let mut app = App::empty();
app.add_plugins((
TaskPoolPlugin::default(),
TypeRegistrationPlugin::default(),
TransformPlugin::default(),
RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(1.0),
TimePlugin,
MainSchedulePlugin,
))
.add_event::<AppExit>();
...
app
.insert_resource(TimeUpdateStrategy::ManualDuration(Duration::from_secs_f32(
1.0 / ticks_per_second as f32,
))); Here's my system code for moving each player pub fn player_move_handler(
mut player_entity_tracker: ResMut<PlayerEntityTracker>,
mut q_player_entity: Query<((&Collider, &mut Transform), With<Player>)>,
mut rapier_context: ResMut<RapierContext>,
) -> Result<(), Box<dyn Error>> {
for player_entity in player_entity_tracker.get_player_entities() {
// We only care about the latest movement packet
if let Some(mut last_packet) =
player_entity.remove_incoming_packets_get_last(PacketID::PlayerMove)
{
let new_pos = last_packet.buffer.read_vec2()?;
let ((character_collider, mut transform), _) =
q_player_entity.get_mut(player_entity.entity_id)?;
let curr_pos = transform.translation.as_xy();
let translation = new_pos - curr_pos;
let move_shape_output = rapier_context.move_shape(
translation,
&character_collider,
transform.translation.as_xy(),
0.0,
1.0,
&MoveShapeOptions::default(),
QueryFilter::default(),
|_| {},
);
transform.translation += move_shape_output.effective_translation.extend(0.0);
info!(
"Move player: {} from {} to {}, translation: {}, effective_translation: {}, result: {}",
player_entity.client_id,
curr_pos,
new_pos,
translation,
move_shape_output.effective_translation,
transform.translation.as_xy()
)
}
}
Ok(())
} What could be causing this issue? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Turns out I needed to exclude the collider itself from move_shape, or else it would collide with itself. |
Beta Was this translation helpful? Give feedback.
Turns out I needed to exclude the collider itself from move_shape, or else it would collide with itself.