Use more realistic yaw/pitch speeds

This commit is contained in:
Tom
2020-09-27 16:32:06 -07:00
parent 670799df8d
commit 93cb674bd2

View File

@ -17,8 +17,8 @@ const (
playerHeight = 1.8 playerHeight = 1.8
resetVel = 0.003 resetVel = 0.003
maxYawChange = 18 maxYawChange = 7
maxPitchChange = 11 maxPitchChange = 5
stepHeight = 0.6 stepHeight = 0.6
minJumpTicks = 14 minJumpTicks = 14
@ -291,3 +291,10 @@ func (s *State) computeCollisionYXZ(bb, query AABB, vel path.Point, w World) (ou
bb = bb.Offset(0, 0, outVel.Z) bb = bb.Offset(0, 0, outVel.Z)
return bb, outVel return bb, outVel
} }
// AtLookTarget returns true if the player look position is actually at the
// given pitch and yaw.
func (s *State) AtLookTarget(yaw, pitch float64) bool {
dYaw, dPitch := math.Abs(modYaw(yaw, s.Yaw)), math.Abs(pitch-s.Pitch)
return dYaw <= 0.8 && dPitch <= 1.1
}