diff --git a/src/physics.rs b/src/physics.rs index 3937d2f..bda76a1 100644 --- a/src/physics.rs +++ b/src/physics.rs @@ -1342,7 +1342,7 @@ fn teleport(body:&mut Body,touching:&mut TouchingState,style:&StyleModifiers,poi //touching.recalculate(body); } -fn run_teleport_behaviour(teleport_behaviour:&Option,game:&mut GameMechanicsState,models:&PhysicsModels,modes:&Modes,style:&StyleModifiers,touching:&mut TouchingState,body:&mut Body)->Option{ +fn run_teleport_behaviour(teleport_behaviour:&Option,game:&mut GameMechanicsState,models:&PhysicsModels,modes:&Modes,style:&StyleModifiers,touching:&mut TouchingState,body:&mut Body,model:&ModelPhysics)->Option{ match teleport_behaviour{ Some(crate::model::TeleportBehaviour::StageElement(stage_element))=>{ if stage_element.force||game.stage_id{ - //telefart - None + let origin_model=model; + let destination_model=models.get_wormhole_model(wormhole.destination_model_id)?; + //ignore the transform for now + Some(teleport(body,touching,style,body.position-origin_model.transform.translation+destination_model.transform.translation)) } None=>None, } @@ -1423,7 +1425,7 @@ impl crate::instruction::InstructionConsumer for PhysicsStat //check ground self.touching.insert_contact(c.model,c); //I love making functions with 10 arguments to dodge the borrow checker - run_teleport_behaviour(&general.teleport_behaviour,&mut self.game,&self.models,&self.modes,&self.style,&mut self.touching,&mut self.body); + run_teleport_behaviour(&general.teleport_behaviour,&mut self.game,&self.models,&self.modes,&self.style,&mut self.touching,&mut self.body,model); //flatten v self.touching.constrain_velocity(&self.models,&mut v); match &general.booster{ @@ -1460,7 +1462,7 @@ impl crate::instruction::InstructionConsumer for PhysicsStat PhysicsCollisionAttributes::Intersect{intersecting,general}=>{ //I think that setting the velocity to 0 was preventing surface contacts from entering an infinite loop self.touching.insert_intersect(c.model,c); - run_teleport_behaviour(&general.teleport_behaviour,&mut self.game,&self.models,&self.modes,&self.style,&mut self.touching,&mut self.body); + run_teleport_behaviour(&general.teleport_behaviour,&mut self.game,&self.models,&self.modes,&self.style,&mut self.touching,&mut self.body,model); }, } },