Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

$player->getMotion()

Comments in 'Plugin Development' started by dxm_hippie, Jul 30, 2016.

  1. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    PHP:
    $player->getMotion()
    Always returns...
    Code:
    object(pocketmine\math\Vector3)#33768 (3) {
      ["x"]=>
      int(0)
      ["y"]=>
      int(0)
      ["z"]=>
      int(0)
    }
    
    Why is this? and how can i get the real motion of a player? i have also tried $player->motionX yadda yadda..
  2. CaptainKenji17
    Offline

    CaptainKenji17 Active Member

    Joined:
    Apr 22, 2014
    Posts:
    252
    Minecraft User:
    CaptainKenji17
    I cant code and know nothing but try getMotionX Y Z
  3. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    I think that would be the same as $player->motionX y z..but will try :p
  4. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    I got it do do something using $player->speed..but it dose not move right and in opposite directions lol i dont see why getMotion() would return a useless vector3..is it because im using it on playerMoveEvent?..
    Last edited: Jul 30, 2016
  5. ImagicalGamer
    Offline

    ImagicalGamer Active Member

    Joined:
    Feb 25, 2016
    Posts:
    141
    Minecraft User:
    ImagicalGamer
    PHP:
    $player->getMotion()->getX();
    $player->getMotion()->getY();
    $player->getMotion()->getZ();
    Or if your trying to get a players speed do:
    PHP:
    $player->getMovementSpeed() // Genisys
    $player->getSpeed() //ImagicalMine
    //not sure for PocketMine
  6. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    Motion x y z are always 0...
    I don't think using different api methods will change that?
  7. ImagicalGamer
    Offline

    ImagicalGamer Active Member

    Joined:
    Feb 25, 2016
    Posts:
    141
    Minecraft User:
    ImagicalGamer
    It always returns 0?
  8. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    The main goal here is to.

    PHP:
    $entity->setMotion($player->getMotion());
    Last edited: Jul 30, 2016
  9. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    yes like showed in my first comment here.
  10. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    I am calling this on playerMoveEvent and I feel that may be the issue..because the players new motion hasn't been calculated yet?..
    Last edited: Jul 31, 2016
  11. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    You see? This question is for PocketMine, This is not a Genisys/ImagicalMine forum.
    SOFe likes this.
  12. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Are you doing disguise plugin?
  13. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    BlockHunt
  14. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    Any thoughts?..I can't test this atm.
  15. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Spawn another entity with same entityID and this thread won't be interesting for you anymore ;)
    Nawaf_Craft1b likes this.
  16. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    Soo..your saying make the block entity with the same entity id as the player? o_O
  17. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    Not really. PlayerMoveEvent is something fired internally every tick, even if the player didn't change his motion (speed).

    Try playing with $player->speed.
  18. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    I did a little bit and it did make the block move..but all funky. It slid like ice in opposite directions as the player moving. lol I may be able to figure it out though.
  19. ImagicalGamer
    Offline

    ImagicalGamer Active Member

    Joined:
    Feb 25, 2016
    Posts:
    141
    Minecraft User:
    ImagicalGamer
    ImagicalMine -> Genisys -> PocketMine-MP

Share This Page

Advertisement