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

Solved Check player's rotation

Discussion in 'Development' started by MalakasPlayzMCPE, Apr 2, 2018.

  1. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    How to check the rotation of a player? I mean how to check if the player looks on X or Z? Is there any compass plugin that shows you a pop-up with your rotation?
     
  2. DiamondGamer30

    DiamondGamer30 Baby Zombie

    Messages:
    175
    GitHub:
    diamondgamermcpe
    Check PureEntitiesX. I honestly have no idea how to work with motions yet but in PureEntitiesX, they have MobAI which works with motions and rotations and stuff.
     
  3. Daniktheboss

    Daniktheboss Baby Zombie

    Messages:
    144
    GitHub:
    daniktheboss
    Why do you comment on a post if you dont know the answer?
     
  4. LewBr

    LewBr Zombie

    Messages:
    385
    GitHub:
    lewbr
    You can get the Yaw and Pitch
     
  5. DiamondGamer30

    DiamondGamer30 Baby Zombie

    Messages:
    175
    GitHub:
    diamondgamermcpe
    Why are you full of negativity, Danik. I tried to help.
     
    xXNiceAssassinlo YT likes this.
  6. Marabou

    Marabou Baby Zombie

    Messages:
    137
    GitHub:
    wiligangster
    Because you don't help this person (Development Section)
     
  7. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    Use Player->getTargetBlock()
    PHP:
    /** @var Player $player */
    $targetVector $player->getTargetBlock(99)->asVector3();
     
  8. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    Hmmm. I asked how to check if the player looks on X or Z?
     
  9. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Entity::$yaw returns the rotation along the XZ-axis and Entity::$pitch the Y-axis.
     
  10. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    Ok, how to count the yaw?
    PHP:
    if($player-yaw == (what to put here?)){
    //code
    }
     
  11. Tee7even

    Tee7even Slime

    Messages:
    81
    GitHub:
    tee7even
    Yaw is measured in degrees. So you'll need to compare it to some numbers between 0 and 360.
    PHP:
    if ($player->getYaw() === 90) {
        
    $player->sendMessage("A right angle");
    }
    But I think there may be an easier way to solve your problem...
    Don't you want to just check if player's facing east/west/south/north? Because there is the getDirection method.
    PHP:
    if ($player->getDirection() === 2) {
        
    $player->sendMessage("North");
    }
     
    Last edited: Apr 2, 2018
  12. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    Thanks!
     
  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.