mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
Include eye height in Living->lookAt() calculation (#4440)
This commit is contained in:
parent
dca5a9d8ea
commit
b9b1ba9526
@ -772,7 +772,7 @@ abstract class Living extends Entity{
|
||||
*/
|
||||
public function lookAt(Vector3 $target) : void{
|
||||
$horizontal = sqrt(($target->x - $this->location->x) ** 2 + ($target->z - $this->location->z) ** 2);
|
||||
$vertical = $target->y - $this->location->y;
|
||||
$vertical = $target->y - ($this->location->y + $this->getEyeHeight());
|
||||
$this->location->pitch = -atan2($vertical, $horizontal) / M_PI * 180; //negative is up, positive is down
|
||||
|
||||
$xDist = $target->x - $this->location->x;
|
||||
|
Loading…
x
Reference in New Issue
Block a user