I tried to set particles to the right site of a player. But if he moves the particles aren't moving with the player. My code: PHP: $level = $player->getLevel(); $x = $player->x; $y = $player->y; $z = $player->z;$level->addParticle(new FlameParticle(new Vector3($x, $y+1, $z+1)));
PHP: class GameSender extends PluginTask { public $prefix = ""; public function __construct($plugin) { $this->plugin = $plugin; $this->prefix = $this->plugin->prefix; parent::__construct($plugin); } public function onRun($tick) { foreach ($this->plugin->getServer()->getOnlinePlayers() as $player) {$level = $player->getLevel(); $x = $player->x; $y = $player->y; $z = $player->z; $name = $player->getName();$level->addParticle(new FlameParticle(new Vector3($x, $y+1, $z+1))); } }}
The task runs. The I can see the particles. Did u read my question??? If I use $player->z; and the player turns around the particles aren't anymore at the players right side
You need some math for that. PHP: $yaw = $player->yaw;$right = $yaw + 180;$x = cos($right * M_PI / 180) + $player->x;$z = sin($right * M_PI / 180) + $player->z;$y = $player->y + 1; Test it, tell me if if it works.
The particle doesn't show when the player moves only when the task runs. So if you want it to move with the player use \pocketmine\event\player\PlayerMoveEvent. WARNING: this may cause lag to your server.
... I know how to do that. Pls read my question... I want to add particles to the right side of a player..
Yes, it's important. Every small detail is important to future developers who might want to do the same. Anyways this might help: PHP: //Note: this only spawns a small particle at once two blocks to the right side of a player//Again, you did not specify the physical shape that you want the particle to have$blocks2right = 2;//blocks you want it to go to the right.$pos = clone $player->getPosition();$pos->x += $blocks2right;$pos->level->addParticle(new FlamingParticle($pos));