Set Velocity for .launchProjectile()

Discussion in 'Plugin Development' started by weirdo16, Jun 24, 2014.

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

    weirdo16

    Hi!

    How do you define a velocity for an arrow shot by a player using .launchProjectile()? The docs say you can specify velocity as a second parameter, but I can't figure out what to put in. I'd like it to shoot maybe 50-100 blocks pretty quickly, but in the same direction that the player is facing. I have this, but it doesn't shoot very far.
    Code:java
    1. player.launchProjectile(Arrow.class);
     
  2. Offline

    fireblast709

    weirdo16 that method returns an Arrow, just use it's velocity methods
     
  3. Offline

    Pik0

    Code:java
    1. Projectile projectile = player.launchProjectile(Arrow.class);
    2. projectile.setVelocity(yourvector);


    Easy way to multiply projectile's velocity:
    Code:java
    1. projectile.setVelocity(projectile.getVelocity().multiply(2));


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  4. Offline

    Plo124

    Pik0
    Anything over 4 would offset the Projectile from the client and server, making the projectile look like its going another direction
     
  5. Offline

    weirdo16

    OK, thanks everyone! It works now!
     
Thread Status:
Not open for further replies.

Share This Page