# Shooting an arrow in all directions.

Discussion in 'Spigot Plugin Development' started by GlitchedTurtle, May 21, 2016.

1. ### GlitchedTurtle

Hey Guys!

I am wondering how you would shoot an arrow in all possible directions.

I could use randoms but that is inconsistent.

I know how to shoot an arrow, it is just the vectors that i am having a problem with.

2. ### Tux2

You've got velocity and directions in a vector that you have to worry about. When you say all directions are you saying that you want to fire a volley of arrows in a circle around a location, or in a half sphere around the location?

3. ### GlitchedTurtle

a sphere. So let's say the location is in the sky. Then it would shoot downwards as well.

4. ### FlyingLlama

You could take a look at the code people use to make rings or circular bursts of particles, the math would be nearly identical. If not, there are simple tutorials online for the math needed to calculate rings or curves, it is about the same in all languages.

5. ### Tux2

You could use a for loop to loop through a list of x, y, z vectors, then multiply them to suit your purpose. I'm going to say go and experiment with them, see what looks good to you. Vectors always seem to be part science, part experimentation when it comes to getting them to work the way you want.

6. ### FlyingLlama

Vectors play fairly nice. If you want pure evil, try quaternions.
a complex number of the form w + xi + yj + zk, where w, x, y, z are real numbers and i, j, k are imaginary units that satisfy certain conditions.

7. ### GlitchedTurtle

what is the lowest and greatest value of the x,y and z of vectors?

8. ### Msrules123

Minimum: 4.9 E-324
Maximum: 1.7976931348623157 E308
The fields are stored as doubles, those are the maximum and minimum values of a double.

9. ### GlitchedTurtle

lol. If i spawn that many arrows in then most clients would probably crash lol.

10. ### Stef

You would need to determine how many arrows you want to spawn. I think 100 would certainly do, but you can change it of course.