Set Player pitch and yaw decently

Discussion in 'Plugin Development' started by Muizers, Nov 5, 2012.

Thread Status:
Not open for further replies.
  1. I need to set pitch and yaw of a player, but it's kinda giving me a hard time to do, and also it fires a PlayerMoveEvent.
    • What is the best way to change the pitch and yaw? I tried to use Player.teleport(Location loc) where loc is a clone of the location of the player with pitch and yaw changed
    • Is it possible to change the pitch and yaw without firing PlayerMoveEvent?
    • Note here that sending a PlayerLook packet doesn't work correctly, and gives LOADS of glitches afterwards
     
  2. Offline

    Metal Julien

    Code:
    //On Command
     
    Player p = (Player) sender;
     
    Location loc = p.getLocation();
     
        loc.setPitch(90F);
        loc.setYaw(90F);
    p.teleport(loc);
    
    Why not sth like this?
     
  3. Offline

    fireblast709

    Metal Julien he apparently already tried that, and it did not work (or suits his needs) ;3
     
    Metal Julien likes this.
  4. Exactly, cause it fires PlayerMoveEvent. Well that is still not the biggest problem, the biggest problem is that calling teleport is quite heavy for the server as the server does a lot of unnecessary and sometimes heavy checks after it, and also that teleport glitches a bit for the player, because the client interprets it as kind of a 'rough' movement.
    Also when calling teleport when only changing pitch and yaw, all client-sent movement in the next few ticks is ignored so it gives a glitchy effect.
     
  5. Offline

    FTWinston

    Well unless there's a packet that the server could send to the client that sets their pitch and yaw without affecting their position, there's going to be no way around that, whatever method you use.
     
  6. I tried all of them and they glitch unpreventably.

    So yeah, I've given up.
     
  7. Offline

    Rudonator

    You can do

    Player player = (Player) sender;
    float pitch = player.getEyeLocation().getPitch();
    float yaw = player.getEyeLocation().getYaw();
    Location location = new Location(x, y, z, yaw, pitch);
    player.teleport(location);

    You have to change the x, y, z to the location you want.
     
  8. Offline

    Janmm14

  9. Rudonator Did you even read my post?

    Janmm14 Thanks but I already did it through PacketWrapper/ProtocolLib.
     
  10. Offline

    spy85

    It works, you are just doing it incorrectly. Use f3 and do not look at f:4 or f:1 etc. but look at the larger number in decimals next to it and use that.
     
Thread Status:
Not open for further replies.

Share This Page