World.spawnArrow() issue

Discussion in 'Plugin Development' started by perwin, Mar 23, 2013.

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

    perwin

    Hello,
    I have problem with using spawnArrow() method.
    My example code:
    Code:java
    1. Arrow arrow = player.getWorld().spawnArrow(location, vector, (float) 0.6, 12);
    2. arrow.setShooter(player);

    Spawning of arrows works, but it doesn't damage any entity. Why?
    Thanks for replies.
     
  2. Offline

    Zarkopafilis

    Nonono.
    Try :
    Code:
    player.launchProjectile(Arrow.class);
    //and add a nice bow fire effect if you want
    player.playEffect(player.getLocation(), Effect.BOW_FIRE , 0);
     
  3. Offline

    perwin

    Yes, but when I use this method, I can't set the spread and start location of the arrow (I want arrows to fall from the sky).
     
  4. Offline

    Zarkopafilis

    perwin you set the shooter as a player
     
  5. Offline

    perwin

    Yes, it did that, because I though that then it will cause the damage, but it didn't work.
    Anyway I want the arrows to fall from the sky.
     
  6. Well if spawn() is really glitchy then you can use player.launchProjectile() and store the entity it returns and you can then change the location of the entity and the velocity.
     
  7. Offline

    perwin

    I need some other solution, because it isn't good idea to teleport player if I shoot 2 arrows per second from different locations.
     
  8. perwin
    I didn't say anything about teleporting player...
    Code:
    Arrow arrow = player.launchProjectile(Arrow.class);
    arrow.teleport(location); // your in-sky location
    arrow.setVelocity(direction.multiply(speed)); // you must add a random vector to the vector if you want spread
     
  9. Offline

    perwin

    Thanks, in API (here) I just missed the .teleport method, I was looking for some .setLocation method.
     
Thread Status:
Not open for further replies.

Share This Page