Arrows and velocities

Discussion in 'Plugin Development' started by ItzHectik, Feb 21, 2015.

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

    ItzHectik

    So I want to make it when I shoot a bow and the arrow hits the ground, it launches the player in the same direction as they shot the arrow.

    p.setVelocity(p.getLocation().getDirection().multiply(3).setY(p.getVelocity().getY() + 0.75));

    If I use this, the player can turn their head and it launches them in the wrong direction. Is there a way I can get the direction from the player towards the arrow?

    p.setVelocity(a.getLocation().getDirection().multiply(3).setY(p.getVelocity().getY() + 0.75));

    This could possibly work with a bit of tweaking. I've found that .getDirection() launches the player in the opposite direction of the arrow. If there's some way to reverse it, that would work.

    Thank you for your time. :)

    EDIT: Also, how can I insert code so it's not normal text? I've seen people do it on other forum pages. Thanks. :)
     
  2. Moved to Plugin Development
     
  3. Offline

    xTrollxDudex

    You can use
    Code:
    [code=java]Code here
    [/code]
    To format your code.

    Try getting the direction of the arrow, just the X and Z. You can transfer those into player's velocity using a Vector(x, 0, z)
     
  4. Offline

    ItzHectik

    Are you able to give an example of what you mean?
     
  5. Offline

    ItzHectik

Thread Status:
Not open for further replies.

Share This Page