Skip to content

Commit

Permalink
Reduced deltas for player movement, significantly smoother player mov…
Browse files Browse the repository at this point in the history
…ement and rotation (#883)

Send movement to viewers if the player moved more than 0.01 blocks in a tick or rotated more than 1 degree in any direction.
  • Loading branch information
dktapps committed May 5, 2017
1 parent 11f35d2 commit 76ceddf
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/pocketmine/Player.php
Original file line number Diff line number Diff line change
Expand Up @@ -1544,7 +1544,7 @@ protected function processMovement($tickDiff){
$delta = pow($this->lastX - $to->x, 2) + pow($this->lastY - $to->y, 2) + pow($this->lastZ - $to->z, 2);
$deltaAngle = abs($this->lastYaw - $to->yaw) + abs($this->lastPitch - $to->pitch);

if(!$revert and ($delta > (1 / 16) or $deltaAngle > 10)){
if(!$revert and ($delta > 0.0001 or $deltaAngle > 1.0)){

$isFirst = ($this->lastX === null or $this->lastY === null or $this->lastZ === null);

Expand All @@ -1567,7 +1567,6 @@ protected function processMovement($tickDiff){
$this->level->addEntityMovement($this->x >> 4, $this->z >> 4, $this->getId(), $this->x, $this->y + $this->getEyeHeight(), $this->z, $this->yaw, $this->pitch, $this->yaw);

$distance = $from->distance($to);

//TODO: check swimming (adds 0.015 exhaustion in MCPE)
if($this->isSprinting()){
$this->exhaust(0.1 * $distance, PlayerExhaustEvent::CAUSE_SPRINTING);
Expand Down

0 comments on commit 76ceddf

Please sign in to comment.