You can use Zombie AI: https://github.com/iTXTech/Genisys/blob/master/src/pocketmine/entity/Zombie.php#L139