shoot player

Discussion in 'Spigot Plugin Development' started by TheFuzzyHead5, May 27, 2017.

  1. So vectors have always been something I've never fully understood.

    How would I go about making a player shoot exactly back, almost like a forcefield?
     
  2. to find a direction vector from point A to B you would do (B - A)
    after you have your vector, AB, simply spawn the projectile and set its vector to AB.
     
  3. To eleborate on what iSoda said, the code would looking something like this:

    Code (Text):

    vector = player.getLocation - shootLoction()
    player.getWorld().SpawnEntity(Class.Arrow).setVector(vector)
     
    this isn't the exact code, clearly you'll need to name your variable and spawn the entity properly.
     
  4. The code above should work, be sure to convert the location into a vector, via loc.toVector()