fix depenetration panic (#98)

This commit is contained in:
PROMETHIA-27
2025-12-22 07:22:27 -05:00
committed by GitHub
parent da5c0f8fb7
commit dd01b03526
6 changed files with 280 additions and 17 deletions

View File

@@ -6,9 +6,8 @@ use crate::{
physics_layers::GameLayer,
player::LocalPlayer,
};
use avian3d::prelude::SpatialQuery;
use avian3d::prelude::{
Collider, LayerMask, PhysicsLayer as _, ShapeCastConfig, SpatialQueryFilter,
Collider, LayerMask, PhysicsLayer as _, ShapeCastConfig, SpatialQuery, SpatialQueryFilter,
};
use bevy::prelude::*;

View File

@@ -4,9 +4,8 @@ mod heads_ui;
mod pause;
pub use backpack_ui::{BACKPACK_HEAD_SLOTS, BackpackUiState};
pub use heads_ui::{HeadsImages, UiHeadState};
use bevy::prelude::*;
pub use heads_ui::{HeadsImages, UiHeadState};
pub fn plugin(app: &mut App) {
app.add_plugins(heads_ui::plugin);

View File

@@ -23,6 +23,7 @@ use bevy::{
};
use bevy_replicon::prelude::{ClientId, Replicated, SendMode, ServerTriggerExt, ToClients};
use happy_feet::debug::DebugInput;
use rand::Rng;
use serde::{Deserialize, Serialize};
#[derive(Component, Default, Serialize, Deserialize, PartialEq)]
@@ -69,7 +70,15 @@ pub fn spawn(
) -> Option<Entity> {
let spawn = query.iter().next()?;
let transform = Transform::from_translation(spawn.translation + Vec3::new(0., 3., 0.));
// This offset helps prevent players from getting stuck inside each other on spawn and causing a perpetual
// motion machine.
let random_offset = Vec3::new(
rand::thread_rng().gen_range(-0.01..0.01),
0.0,
rand::thread_rng().gen_range(-0.01..0.01),
);
let transform =
Transform::from_translation(spawn.translation + Vec3::new(0., 3., 0.) + random_offset);
let id = commands
.spawn((

View File

@@ -1,8 +1,7 @@
use crate::protocol::PlayerId;
use bevy::prelude::*;
use serde::{Deserialize, Serialize};
use crate::protocol::PlayerId;
// TODO: remove in favour of client side change detection
#[derive(Clone, Event, Serialize, Deserialize, PartialEq)]
pub struct ClientHeadChanged {