1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Teleport Not Workinh

Discussion in 'Development' started by Bintang Putra, Jun 20, 2017.

  1. Bintang Putra

    Bintang Putra Witch

    Messages:
    63
    GitHub:
    chaostixzix
    Hi, I'm trying to teleport player to
    x = 1
    y = 1
    z = 1

    this is my code
    PHP:
    $pos = new Vector3(111);
    $player->setLevel($this->getServer()->getLevelByName("world"));
    $player->teleport($pos);
    var_dump("working");
    The console says working but the player did not teleported
     
  2. Thouv

    Thouv Slime

    Messages:
    84
    GitHub:
    adeynes
    Is $player an instance of \pocketmine\Player? Do you have
    PHP:
    use pocketmine\math\Vector3
    at the top of your life? If not, try changing Vector3 to \pocketmine\math\Vector3. Do you get any errors? Also, try setting debug to 2 in pocketmine.yml
     
  3. Bintang Putra

    Bintang Putra Witch

    Messages:
    63
    GitHub:
    chaostixzix
    Yep, i used instaceof and already loaded the Vector3
     
  4. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    It's not the best practice to use setLevel() as far as I know. (citation required) This is what the teleport function is made for. Instead of creating a vector3 and setting the level, you can create a new Position and teleport the player there. In code:
    PHP:
    $pos = new Position(111$this->getServer()->getLevelByName("world"));
    $player->teleport($pos);
     
    Kenn Fatt and corytortoise like this.
  5. Bintang Putra

    Bintang Putra Witch

    Messages:
    63
    GitHub:
    chaostixzix
    Thanks :D
    i'll try immediatelly
     
  6. Zayd

    Zayd Witch

    Messages:
    55
    GitHub:
    ZaydPE
    There is however a teleportion bug in PMMP concerning levels and Position.
     
  7. Bintang Putra

    Bintang Putra Witch

    Messages:
    63
    GitHub:
    chaostixzix
    so, i just need to wait?
     
  8. Zayd

    Zayd Witch

    Messages:
    55
    GitHub:
    ZaydPE
    I'm not to sure, the issue on GitHub is here if you want to find out more information.
     
  9. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    The error occures, but as far as I know the actual teleporting works fine. I myself haven't had any trouble with the actual teleporting yet, except for the error showing up.
     
  10. Zayd

    Zayd Witch

    Messages:
    55
    GitHub:
    ZaydPE
    You can try and use the teleportImmediate() function?
     
  11. Kenn Fatt

    Kenn Fatt Slime

    Messages:
    82
    GitHub:
    kennfatt
    Its actually work
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.