Problems with yaw (and probably pitch)

Discussion in 'Plugin Development' started by Zupsub, Aug 13, 2014.

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

    Zupsub

    Hey there!

    Currently I have to deal with PlayerMoveEvent and it's #getTo.getYaw().
    The values returned from that are just strange. If I turn right, it is increased upt o 1000, 2000 and it seems to be no ending. But a few ticks, it goes down to about 100, see:
    [14:18:48] [Server thread/INFO]: 3083.8303
    [14:18:48] [Server thread/INFO]: 3098.6804
    [14:18:48] [Server thread/INFO]: 218.68042
    [14:18:48] [Server thread/INFO]: 3105.8804
    [14:18:48] [Server thread/INFO]: 3116.6804
    [14:18:48] [Server thread/INFO]: 3131.6804

    If I turn left, it is decreased down to -2000, -3000 without an ending. The same strange thing (some ticks the value is only -200, -300) happens then.

    I'm a little bit confused how to handle this method, I want to monitor how much the player moved his had, so basically getFrom.getYaw() - getTo.getYaw() but with this values I get 10 one tick and 2800 next tick.

    Regards
     
  2. Offline

    Totom3

    Zupsub a yaw of 3098 is the same as 218 since Bukkit always does something like yaw %= 360 to check where the player is facing. (3098 % 360 = 218) I believe you can use those big values safely, but just to make sure you can do the operation yourself. Also, in your last paragraph, you have proven why Bukkit does not reset immediately the yaw when it goes over 360 :

    If the old yaw was 350, the new one 370, and if Bukkit would have changed 370 to 10, you would have 350 - 0, which would obviously return 350. Your plugin would then think that the player almost did a complete rotation in 1-2 ticks.
     
Thread Status:
Not open for further replies.

Share This Page