Hello, I've been trying to make an arrow go forward from a player. The javadocs say that you can spawn an arrow with: spawnArrow(Location location, Vector velocity, float speed, float spread) I spawned it at the players location, with the players velocity, the speed 0.8F, and the 12F spread. It went strait down from the players head. I'm assuming it's the velocity. Can anybody help?
Try setting the velocity to: player.getLocation().getDirection() or player.getLocation().getDirection().multiply(2)
Thanks I'll try it right now. It didn't work. Do you want to join our test server and see our problem? EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Try this. Not sure if it will work, but I think it is your best bet. Code: Location loc = player.getLocation(); // Get the player Location loc.add(0, 1, 0); //Add 1 to the Y, makes the arrow go at chest level instead of feet Arrow arrow = player.getWorld().spawn(loc, Arrow.class); //Spawn Entity arrow.setShooter(player); //Set the shooter to your player
The arrow is colliding with the player and falls down, you need to spawn it in front of the player. Convert that direction into a normalized vector (just see the methods available and you'll see what I mean) then add that to the location and it should be in front of the player... keep the + 1 y addition as well so it spawns in front of your head, not your feet.
I got it working, by setting the speed float to "1" it only shoots 1 arrow... Now how do i adjust the speed :S and It shoots behind the player, because of that +1 x but if i turn around... EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Got it too shoot for sure... Increased the speed... Just the accuracy is terrible since im using getEye Location for the location of the arrow.
try arrow.setFallDistence(0); or setFallDistence(10000) EDIT by Moderator: merged posts, please use the edit button instead of double posting.