walk event

This commit is contained in:
Quaternions 2023-09-08 14:11:24 -07:00
parent f600092f13
commit e18e8a9a7d

View File

@ -54,6 +54,7 @@ impl PhysicsState {
if applied_friction*applied_friction<diffv.length_squared() { if applied_friction*applied_friction<diffv.length_squared() {
self.body.velocity+=applied_friction*diffv.normalize(); self.body.velocity+=applied_friction*diffv.normalize();
} else { } else {
//EventEnum::WalkTargetReached
self.body.velocity=targetv; self.body.velocity=targetv;
} }
} }
@ -74,6 +75,11 @@ impl PhysicsState {
event:crate::event::EventEnum::StrafeTick event:crate::event::EventEnum::StrafeTick
}); });
} }
fn next_walk_event(&self) -> Option<EventStruct> {
//check if you are accelerating towards a walk target velocity and create an event
return None;
}
} }
impl crate::event::EventTrait for PhysicsState { impl crate::event::EventTrait for PhysicsState {
@ -96,9 +102,13 @@ impl crate::event::EventTrait for PhysicsState {
//check for collision start events (against every part in the game with no optimization!!) //check for collision start events (against every part in the game with no optimization!!)
for &model in self.world.models { for &model in self.world.models {
best.collect(self.predict_collision(&model)); best.collect(self.predict_collision(&model));
if self.grounded {
//walk maintenance
best.collect(self.next_walk_event());
}else{
//check to see when the next strafe tick is
best.collect(self.next_strafe_event());
} }
//check to see when the next strafe tick is
best.collect(self.next_strafe_event());
best.event() best.event()
} }
} }