Solved Going mad.. can't get Player#teleport to keep the direction they're facing.

Discussion in 'Spigot Plugin Development' started by Xemor, Jan 20, 2020.

  1. Code (Java):
    Location eyeLocation = player.getEyeLocation();
    player.teleport(location);
    player.getEyeLocation().setYaw(eyeLocation.getYaw());
    player.getEyeLocation().setPitch(eyeLocation.getPitch());
    That's the small code snippet I'm using that's relevant. The player is being teleported, but it's not keeping the direction. They're always facing south. I've used this code before and it's always worked for me I'm bamboozled.
     
  2. set the yaw/pitch of the location theyre being teleported to
     
  3. Have you tried using player.getLocation() everywhere instead of player.getEyeLocation()? getEyeLocation() might not contain pitch and yaw.
     
  4. I'll try that now _Donut_.
     
  5. That worked, thanks a lot. I spent ages running around in circles over that.