Solved Launchpad Velocity problems

Discussion in 'Plugin Development' started by yupie_123, May 21, 2014.

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

    yupie_123

    What I want is that if a player steps on a pressure plate, they get launched forward in a parabola shape about 7 blocks above ground:

    Code:
          | |
        |    |
      |        |
     |          |
    |            |
    START       END
    Something like that.
    I have the following code:
    Code:java
    1. Vector v = new Vector(p.getVelocity().getX(), p.getVelocity().getY() + 5, p.getVelocity().getZ());
    2. p.setVelocity(p.getLocation().getDirection().multiply(4).add(v));
    3.  


    But this only launches the player forward when he triggers the pressure plate, it doesn't launch him upwards.

    Any idea how I can do this?
     
  2. Don't add a vector, do setY(amount); before the multiply
     
  3. as Bram0101 said, youre adding same vector twice, do something like that:
    p.setVelocity(p.getEyeLocation().getDirection().setY(Y).multiply(number));
     
  4. Offline

    yupie_123

    Bram0101 Now I have:
    Code:java
    1. p.setVelocity(p.getLocation().getDirection().setY(7).multiply(4));

    But this still doesn't work

    I tried this aswell, replacing Y with 7 and number with 4 but it didn't work either, it just launches the player forward, not up.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  5. yupie_123 try
    Vector v = p.getEyeLocation().getDirection().multiply(1); //Note: multiply 1 useless, just for future usage.
    v.setY(10); //Try playing with that, when im setting it to 1 its launch the player quite high.
    p.setVelocity(v);
     
  6. Offline

    Funergy

    Why 2 lines of code and not 1 :p
    Code:
    e.getPlayer().setVelocity(e.getPlayer().getLocation().getDirection().multiply(4).setY(1));
     
    Someone_Like_You likes this.
  7. Offline

    yupie_123

    Funergy Well, I did use one line before, but it didn't work so I tried multiple things out such as splitting it in 2 lines etc.

    Someone_Like_You I've been messing around with it a bit now and I also tried using setAllowFlight to see if that was the issue, but it still won't launch the player up, it just launches them forward.
     
  8. Offline

    Funergy

    did you use my code?
    It actually works on my server :)
    play.cubox.org.uk
     
  9. Offline

    yupie_123

    Funergy's code worked! I used iron/gold plates instead and now it works, I also used PlayerMoveEvents instead of Interact.

    Thanks!
     
  10. Funergy well, Il be honest, its quite dumb, but I dont like my coding spreading out to the side, only downwards .. (not scrolling sideways.. haha)
     
  11. Offline

    Stoux

  12. Offline

    yupie_123

    Stoux I'll try this out aswell, thanks!
     
Thread Status:
Not open for further replies.

Share This Page