How do i create a vector going the way a player is looking

Discussion in 'Plugin Development' started by SoThatsIt, Nov 30, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    SoThatsIt

    hi, i am making a plugin and i need to get a vector pointing the direction a player is looking. How would i go about doing this?
     
  2. Offline

    RealDope

    player.getDirection();
    Never used it, don't know if it works. Pretty sure it would return the player's direction as a vector though.
     
  3. Offline

    SoThatsIt

    thanks, that works but you have to do player.getEyeLocation().getDirection()

    1 more question how would i make the mob look the direction the player is looking?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  4. Offline

    rmh4209

    I would use getEntity().getLocation().setPitch(getPlayer().getLocation().getPitch()) and getEntity().getLocation().setYaw(getPlayer().getLocation().getYaw())
     
  5. Offline

    SoThatsIt

    that doesn't seem to work :p if it makes any difference the mob is an ender dragon
     
  6. Offline

    Bryguy

    Yep, that'd be why. Enderdragon works differently than the majority of entities, sans the Ghast. Each and every second of the Enderdragon's existence it's automatically calculating its own pitch/yaw. Best way to get around that that I can see is create a your own Enderdragon that doesn't do that and whose pitch/yaw could be set easily.

    Tip: The enderdragon is backwards, quite literally. Any direction the player is facing would cause the dragon to look the other way. Multiply it any player pitch by 180 degrees to get it correct.
     
Thread Status:
Not open for further replies.

Share This Page