Vectors / Arrows

Discussion in 'Plugin Development' started by Unica, Jul 9, 2015.

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

    Unica

    Quick question,

    I'm messing around with a spell book plugin thing.
    And I'm trying to fire several arrows at once around the player (like 360 degrees around the player).

    Now I understand you need vectors or something, but I cannot figure it out how to use it correctly.

    What I need:
    [​IMG]

    EDIT: http://prntscr.com/7r0pxx

    The blue arrows are arrows you would fire from a bow (using p.launchProjectile(class, vector); )
    The red dot is the player from above.

    I only need to know how I would use the Vector parameter to change the angle the arrow is firing from. Like firing arrows FROM the player but from all around him.

    ty.
     
    Last edited: Jul 10, 2015
  2. You first need to get the locations of where the arrows will fly. Lets say you split a circle in 10 pieces. Then you somehow need to calculate the position of the current gradient (sin & cos). The calculating of a vector between 2 location is the easy part.
     
    Last edited: Jul 10, 2015
  3. Invisible

    Reynergodoy

    access denied for your image
    <Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>B7EA9A683E217310</RequestId><HostId>Cg/wv2yJERk798g12ZBmKvDQr4Dg1GkzYs8nbAKkYP2NzxFMv4WNKpea6y6Im3X7n5mZH8FiVy8=</HostId></Error>

    please dont just drag and drop the images from your computed, instead, use a image hosting website :)
     
  4. Offline

    Unica

  5. [​IMG]
     
  6. Invisible

    Reynergodoy

    lol man why dont you just copy and paste the lightshot url that they give to you instead of copying the image database url?
     
  7. Offline

    Unica

  8. Offline

    mythbusterma

    @Unica

    Do you understand @FisheyLP 's post? If not I could try writing it, as geometry doesn't really come naturally to some people.
     
  9. I tried a little bit with math sin & cos and came to this result:
    Code:
    double radius = 15; //change this how you want it
    double amount = 10; //change this to the amount of arrows you want
    
    for (int i = 0; i < 360; i+= 360 / amount) {
    
    double x = radius * Math.cos(Math.toRadians(i));
    double z = radius * Math.sin(Math.toRadians(i));
    Location endLoc = new Location(startLoc.getWorld(), startLoc.getX() + x, startLoc.getY() + 0.25, startLoc.getZ() + z);
    Vector direction = startLoc.toVector().subtract(endLoc.toVector());
    
    //Spawn arrow
    }
     
    Last edited: Jul 10, 2015
  10. Offline

    Unica

    @mythbusterma

    I used to be good at it, but since my current study doesn't involve 'advanced' maths / geometry, i kind of lost it.
    However, I've read this thread about Calculating with vectory (link), which also uses locations to calculate the vector, but I cannot explain exactly WHY I would use it.

    TL;DR I can't say I am a pro in vector / geometry

    @FisheyLP

    Thanks, I will try it tomorrow.

    Thanks for all your help guys, I appreciate it!
     
Thread Status:
Not open for further replies.

Share This Page