Solved Problems with yaw and pitch teleporting!

Discussion in 'Plugin Development' started by Scrapnix, Jan 23, 2017.

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

    Scrapnix

    Hey, I created already a thread with some yaw and pitch teleporting troubles, but nobody knew anything about this. Now I tried a lot of things and nothing worked!
    My calculations are:
    Code:
        float pitch1 = (float) (((e.getWhoClicked().getLocation().getPitch() + 0) * Math.PI) / 180);
        float yaw1 = (float) ((e.getWhoClicked().getLocation().getYaw() + 90) * Math.PI / 180);
    My 1st variant to teleport a player was:
    Code:
                Location loc = new Location(w, -21.500, 17, 147.500, (float) yaw1, (float) pitch1;
    
    My 2nd variant was:
    Code:
    Location loc = new Location(w, -21.500, 17, 147.500);
                loc.setYaw(yaw3);
                p.getLocation().setPitch(pitch3);
    And my 3rd:
    Code:
    Location loc = new Location(w, -21.500, 17, 147.500);
                p.getLocation().setYaw(yaw3);
                p.getLocation().setPitch(pitch3);
    I hope someone can help me, because last time nobody found the mistake :D
     
  2. Offline

    I Al Istannen

    @Scrapnix
    What do you want to do?
    Why are you doing these calculations?


    We are interested in the end goal, NOT what you think is the solution. This is to ensure we are all on the same page and are choosing the best solution anyone can come up with.
     
  3. @Scrapnix
    What are you actually trying to do? Just add 90 degrees to the player's pitch and yaw? If so, just skip the converting to Radians (which btw can be nicely done using Math.toRadians()).
     
  4. Just add floats together instead of using pi


    Sent from my iPhone using Tapatalk
     
  5. Offline

    Scrapnix

    Ouu, sorry, I forgot to write what I am want to do, I just want to teleport the player with the yaw and pitch and no method worked. @AlvinB do you can give me an example, because I do not understand what you mean. Thanks to you for your answer ;)
     
  6. @Scrapnix
    Yeah well if you just want to retain the yaw and pitch from the previous location, just do as you did in alternative #1, but skip all the adding and converting to radians.
     
Thread Status:
Not open for further replies.

Share This Page