Solved Looking direction

Discussion in 'Development' started by SJames, May 5, 2019.

  1. SJames

    SJames Silverfish

    Messages:
    24
    GitHub:
    sjamese
    Hello,
    How do I get the direction the player looks at, and how do I use it? I want to teleport the player 2 blocks in that direction.
    Thanks.
     
  2. HimbeersaftLP

    HimbeersaftLP Chicken

    Messages:
    1,527
    GitHub:
    HimbeersaftLP
    I don't think it works but have you tried adding the players direction vector twice to the current position?
     
  3. SJames

    SJames Silverfish

    Messages:
    24
    GitHub:
    sjamese
    What do you mean?
     
  4. Levi

    Levi Skeleton

    Messages:
    824
    GitHub:
    captainleviftw
    Exactly what he said
    What else
     
  5. SJames

    SJames Silverfish

    Messages:
    24
    GitHub:
    sjamese
    Thank you soo much... you are not helpful.
     
  6. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    651
    PHP:
    $v $player->getDirectionVector();
    $player->teleport($player->add($v->2$v->2$x->2));
     
  7. Levi

    Levi Skeleton

    Messages:
    824
    GitHub:
    captainleviftw
    You're Welcome
     
  8. SJames

    SJames Silverfish

    Messages:
    24
    GitHub:
    sjamese
    Ok thanks. Why did you put x2? (x*2, y*2 and z*2)
     
  9. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    651
    Instead of doing $v->x + $v->x I did $v->x * 2, it's the same thing. Does the code work though?
     
  10. SJames

    SJames Silverfish

    Messages:
    24
    GitHub:
    sjamese
    Yes, thank you.
     
    HimbeersaftLP likes this.

Share This Page

  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.