Skip to content

FreeMoveControl 5.46.0 ​

final class · pocketmine\entity\ai\hostile\FreeMoveControl · source

Steers a mob that moves freely in three dimensions (flying mobs, mobs swimming in water) straight towards a wanted position. Unlike MoveControl, it produces the full 3D motion of the mob: the current motion is blended towards the wanted velocity by an acceleration factor every tick, which gives the floaty movement of ghasts, vexes, phantoms and guardians. There is no pathfinding: the goals pick reachable points (vanilla flying and swimming mobs mostly move in straight lines too).

Methods ​

__construct() ​

php
public function __construct(\pocketmine\entity\Mob $mob, float $acceleration = 0.1, bool $faceMovement = true)

computeMotion() ​

php
public function computeMotion(\pocketmine\math\Vector3 $motion, float $idleDrag = 0.91) : \pocketmine\math\Vector3

Returns the mob's motion for this tick: the current motion steered towards the wanted position, or slowed down by $idleDrag when there is nowhere to go.

distanceSquaredToWanted() ​

php
public function distanceSquaredToWanted() : float

Returns the squared distance from the mob to the wanted position.

getWantedX() ​

php
public function getWantedX() : float

getWantedY() ​

php
public function getWantedY() : float

getWantedZ() ​

php
public function getWantedZ() : float

hasWanted() ​

php
public function hasWanted() : bool

setAcceleration() ​

php
public function setAcceleration(float $acceleration) : void

setWantedPosition() ​

php
public function setWantedPosition(float $x, float $y, float $z, float $speed) : void

stop() ​

php
public function stop() : void

VanillaMine is a fork of PocketMine-MP, maintained by Luxury Nodes. Not affiliated with the PMMP team or Mojang.