setting pitch

Discussion in 'Plugin Development' started by StickyMan, May 17, 2013.

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

    StickyMan

    hello,
    i have a problem with setting pitch of player.

    code:
    Code:
    if(commandLabel.equalsIgnoreCase("pitch"))
            {
            p.getLocation().setPitch(2);
            p.sendMessage("You've changed your pitch!");
            }
    it does nothing except send the message.
    please help
    thank you.
     
  2. Offline

    JoTyler

    StickyMan Try changing it from
    Code:
    p.getLocation().setPitch(2);
    
    To
    Code:
                    Location pitch = p.getLocation();
                    pitch.setPitch(2);
     
  3. Offline

    StickyMan

    it doesn't work
     
  4. Offline

    JoTyler

    StickyMan Then you can't set a pitch …. if you don't mind me asking why are you trying to set pitch ?
     
  5. Offline

    desht

    player.getLocation() (actually getLocation() for any entity) returns a copy of the player's location, not the actual location object. So just changing the pitch of the object you get won't affect the player. You need to follow up with a player.setLocation(pitch);
     
  6. getLocation() returns an Location Object. If you change this it will never affect the player.
    Use this:

    Code:
     
    if(commandLabel.equalsIgnoreCase("pitch"))
    {
         p.teleport(p.getLocation().setPitch(2));
         p.sendMessage("You've changed your pitch!");
    }
     
    
     
  7. Offline

    StickyMan

    desht
    but there is no really p.setlocation method except teleport the player
     
  8. Offline

    StickyMan

    Oneric-1st
    sorry for double.
    it dosen't work it says to me to rename it in the file
     
  9. Offline

    desht

    Yeah, sorry; use player.teleport(pitch) - that should work fine.
    PHP:
    Location pitch p.getLocation();
    pitch.setPitch(2);
    p.teleport(pitch);
     
  10. Offline

    StickyMan

    desht
    it dosen't seems to work it says rename in file.
    and i can't make a pitch as a location.
     
  11. Than you can rename an variable. p should be the Player who used this command

    Btw it would be better if you say WHAT shall be renamed
     
  12. Offline

    StickyMan

    desht
    it's only makes my player look front but dosen't change the pitch
     
  13. There are two variables : Yaw and Pitch.
    Maybe you want to change the yaw ? Or both ?
     
  14. Offline

    StickyMan

  15. I believe it's the Facing, the rotation of the Player-Body.
     
  16. StickyMan
    Pitch and yaw are in angles, that value is a number representing N/S/E/W, the number in the paranthesis is what you need, -178, which you need to use on yaw, not pitch.
     
  17. Offline

    desht

    The '2' there is just the major compass direction the player is facing - it ranges from 0..3 for the four compass points. The -178.75244 is the player's yaw, -180 being due north. The player's pitch (up/down facing) is not shown at all by F3.

    StickyMan if you're getting errors, we need to see your full code. You clearly have a syntax error in your code somewhere.
     
Thread Status:
Not open for further replies.

Share This Page