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

Check if player is moving in task.

Discussion in 'Development' started by RumDaDuMCPE, Jul 23, 2018.

  1. RumDaDuMCPE

    RumDaDuMCPE Witch

    Messages:
    67
    GitHub:
    RumDaDuMCPE
    Is there a way to check if a player is moving? (Jumping or walking/sprinting and not change in yaw or pitch)
    Example:
    PHP:
    public function onRun(int $currentTick) {
        if (
    $this->player->$this->player->lastX) {
            
    // Do stuff
        
    }
    }
     
    Last edited: Jul 23, 2018
  2. SalmonDE

    SalmonDE Zombie Pigman

    Messages:
    739
    GitHub:
    SalmonDE
    You could use $player->getMotion() and check the motions on the x, y and z axes.
     
  3. RumDaDuMCPE

    RumDaDuMCPE Witch

    Messages:
    67
    GitHub:
    RumDaDuMCPE
    PHP:
    $player->getMotion()->x
    ^^^ would return the player's current x. How can I check for the player's last x coordinate?
    Would
    PHP:
    $player->getLastX
    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.