forked from StrafesNET/strafe-client
only walk if grounded
This commit is contained in:
parent
0632e322cf
commit
fd38502e07
@ -400,7 +400,7 @@ impl PhysicsState {
|
||||
|
||||
fn next_walk_instruction(&self) -> Option<TimedInstruction<PhysicsInstruction>> {
|
||||
//check if you have a valid walk state and create an instruction
|
||||
if self.walk.body_hash==self.body.hash(){
|
||||
if self.grounded&&self.walk.body_hash==self.body.hash(){
|
||||
Some(TimedInstruction{
|
||||
time:self.walk.target_time,
|
||||
instruction:PhysicsInstruction::ReachWalkTargetVelocity
|
||||
@ -754,6 +754,7 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
||||
}
|
||||
PhysicsInstruction::SetWalkTargetVelocity(v) => {
|
||||
//calculate acceleration yada yada
|
||||
if self.grounded{
|
||||
let target_diff=v-self.body.velocity;
|
||||
if target_diff==glam::Vec3::ZERO{
|
||||
self.body.acceleration=glam::Vec3::ZERO;
|
||||
@ -765,6 +766,7 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
||||
self.walk.target_time=self.body.time+((time_delta as f64)*1_000_000_000f64) as TIME;
|
||||
self.walk.body_hash=self.body.hash();//hash check to see if walk target is valid
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user