Solved Shooting arrows in different directions

Discussion in 'Plugin Development' started by HeyAwesomePeople, Jun 27, 2014.

Thread Status:
Not open for further replies.
  1. Hello! I am trying to create a method where once TNT has exploded, it shoots a bunch of arrows in different directions.

    This is what I am doing to shoot the arrows:
    Code:java
    1. Location loc = e.getEntity().getLocation();
    2. loc.getWorld().spawnArrow(loc, loc.getDirection().multiply(0.5), 1F, 1F).setFallDistance(10);
    3. loc.getWorld().spawnArrow(loc, loc.getDirection().multiply(1), 1F, 1F).setFallDistance(10);
    4. loc.getWorld().spawnArrow(loc, loc.getDirection().multiply(1.5), 1F, 1F).setFallDistance(10);
    5. loc.getWorld().spawnArrow(loc, loc.getDirection().multiply(2), 1F, 1F).setFallDistance(10);
    6. loc.getWorld().spawnArrow(loc, loc.getDirection().multiply(2.5), 1F, 1F).setFallDistance(10);
    7. loc.getWorld().spawnArrow(loc, loc.getDirection().multiply(3.0), 1F, 1F).setFallDistance(10);
    8. loc.getWorld().spawnArrow(loc, loc.getDirection().multiply(3.5), 1F, 1F).setFallDistance(10);
    9. loc.getWorld().spawnArrow(loc, loc.getDirection().multiply(4), 1F, 1F).setFallDistance(10);


    Once testing, I noticed it only shot the arrows in one direction. Why is this?
    Iv'e also noticed they shoot really fast and far, is there any way to make them shoot like a max of 15 blocks or around that area?

    Thanks,
    HeyAwesomePeople

    I have this now but it only shoots in the four directions, North, East, South, West. I want it to shoot in North-East, South-East, North-west, and South-West as well;

    Code:java
    1. double i = 1;
    2. while (i <= 8) {
    3. loc.getWorld().spawnArrow(loc, new Vector(0, 1, -i), 1F, 1F).setFallDistance(10);
    4. loc.getWorld().spawnArrow(loc, new Vector(i, 2, 0), 1F, 1F).setFallDistance(10);
    5. loc.getWorld().spawnArrow(loc, new Vector(-i, 1, 0), 1F, 1F).setFallDistance(10);
    6. loc.getWorld().spawnArrow(loc, new Vector(0, 2, i), 1F, 1F).setFallDistance(10);
    7. i = i + 0.5;
    8. }


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

    blablubbabc

    Code:
    for (int x = -1; x <= 1; x++) {
      for (int z = -1; z <= 1; z++) {
        if (x == 0 && z == 0) continue;
        loc.getWorld().spawnArrow(loc, new Vector(x, 0, z).normalize(), 1F, 1F);
      }
    }
     
    HeyAwesomePeople likes this.
Thread Status:
Not open for further replies.

Share This Page