A fireball following mouse and turning back

Discussion in 'Spigot Plugin Development' started by WDireX, Sep 15, 2018.

  1. I made a fireball follows my mouse(sometimes) how i can make this fireball come back the block I was looking ex: player loc: 80 50 -100, the block player looking loc: 90 50 -100, the fireball thrown from player loc: 100(this way going) 50 -100 , now how i can this fireball come back to block player looking at ? Like Half-Life 2 rocket.
  2. I already tryed
    Code (Text):
    f.setVelocity(p.getTargetBlock(s, 100).getLocation().getDirection().multiply(0.50));
    This way, it just going one direction, even when i throw it another direction.
  3. get the fireball vector then substract with the targeted block every 1 second, also make sure you normalize it so it won't speed up
  4. Well you used 100 as a parameter for distance to get the target block. Did you want it to go 100 blocks away?
  5. Isn't that 100 max distance ? And that code already was in runnable, but i'll try substract, thanks.
  6. gettargetblock only gets the block at 100 from you, you could get that block, get his vector and the vector of the fireball, then substract the block vector with the fireball vector, normalise it then set that substracted vector as velocity to the fireball each second, it will follow your mouse like a missile
  7. You're turning a location into a direction, that's why it'll only ever go in 1 direction.
  8. I found a Tutorial, how vectors work, now i get it :)

Share This Page