diff --git a/src/physics.rs b/src/physics.rs index a15704c..b02e48a 100644 --- a/src/physics.rs +++ b/src/physics.rs @@ -1315,7 +1315,9 @@ fn run_teleport_behaviour(wormhole:&Option,models //check ground state.touching.insert(c); //I love making functions with 10 arguments to dodge the borrow checker - run_teleport_behaviour(&general.wormhole,&data.models,&data.modes.get_mode(state.mode_state.get_mode_id()).unwrap(),&state.style,&data.hitbox_mesh,&mut state.mode_state,&mut state.touching,&mut state.body,convex_mesh_id); + if let Some(mode)=data.modes.get_mode(state.mode_state.get_mode_id()){ + run_teleport_behaviour(&general.wormhole,&data.models,mode,&state.style,&data.hitbox_mesh,&mut state.mode_state,&mut state.touching,&mut state.body,convex_mesh_id); + } //flatten v state.touching.constrain_velocity(&data.models,&data.hitbox_mesh,&mut v); match &general.booster{ @@ -1359,7 +1361,9 @@ fn run_teleport_behaviour(wormhole:&Option,models (PhysicsCollisionAttributes::Intersect{intersecting: _,general},Collision::Intersect(intersect))=>{ //I think that setting the velocity to 0 was preventing surface contacts from entering an infinite loop state.touching.insert(c); - run_teleport_behaviour(&general.wormhole,&data.models,&data.modes.get_mode(state.mode_state.get_mode_id()).unwrap(),&state.style,&data.hitbox_mesh,&mut state.mode_state,&mut state.touching,&mut state.body,convex_mesh_id); + if let Some(mode)=data.modes.get_mode(state.mode_state.get_mode_id()){ + run_teleport_behaviour(&general.wormhole,&data.models,mode,&state.style,&data.hitbox_mesh,&mut state.mode_state,&mut state.touching,&mut state.body,convex_mesh_id); + } }, _=>panic!("invalid pair"), }