Avoid direct mutations of Entity->location

This commit is contained in:
Dylan K. Taylor
2022-01-20 21:49:14 +00:00
parent 345ac75aac
commit fc53f3721a
3 changed files with 15 additions and 8 deletions

View File

@ -253,8 +253,10 @@ abstract class Projectile extends Entity{
//recompute angles...
$f = sqrt(($this->motion->x ** 2) + ($this->motion->z ** 2));
$this->location->yaw = (atan2($this->motion->x, $this->motion->z) * 180 / M_PI);
$this->location->pitch = (atan2($this->motion->y, $f) * 180 / M_PI);
$this->setRotation(
atan2($this->motion->x, $this->motion->z) * 180 / M_PI,
atan2($this->motion->y, $f) * 180 / M_PI
);
}
$this->getWorld()->onEntityMoved($this);