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

Solved Looking direction

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

  1. SJames

    SJames Spider Jockey

    Messages:
    35
    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 Fish

    Messages:
    2,402
    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 Spider Jockey

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

    Levi Skeleton

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

    SJames Spider Jockey

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

    MalakasPlayzMCPE Zombie Pigman

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

    Levi Skeleton

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

    SJames Spider Jockey

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

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    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 Spider Jockey

    Messages:
    35
    GitHub:
    sjamese
    Yes, thank you.
     
    HimbeersaftLP likes this.
  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.