Solved Arrow and velocity problem

Discussion in 'Spigot Plugin Development' started by SmokingIsBadMkay, Apr 20, 2017.

  1. So I've created a gun a while back and it works, however even though it hits the target you're looking at it looks like the arrow is going in a other direction, how can I stop this from happening? I tried googleing, testing and even looking at code of other gun plugins but I can't figure out how to make this work.

    Here is my code:
    Code (Text):
                                Arrow projectile = player.launchProjectile(Arrow.class);
                                Vector velocity = player.getLocation().getDirection().multiply(10.0D);
                                projectile.setVelocity(velocity);
                               
                                projectile.setMetadata("Gun Used", new StringMetadata(name));
                                projectile.setMetadata("user", new StringMetadata(player.getName()));
                               
                                PlayerData data = DataManager.getPlayerData(player.getUniqueId());
                                ServerData.addArrowsTrails(projectile, data.selectedArrowTrail());
                               
                                player.getWorld().playSound(player.getLocation(), Sound.ENTITY_FIREWORK_BLAST, 1.5f, .8f);
                                player.setMetadata("Gun cool down", new StringMetadata("Gun cool down"));
                               
                                Snowball sb = player.launchProjectile(Snowball.class);
                               
                                projectile.setGravity(false);
                                sb.setGravity(false);
                                projectile.setPassenger(sb);
     
    Problem:



    Thank you.
     
  2. This direction is normal
     
  3. How is that normal? You can see where it looks like the arrow is and where it actually hits the glass.

    And even if it is, how would I fix this?
     
  4. Oh lol, you have to have the velocity under 3 I think because it just messes up.
    Maybe add like a delay to removing the block at the cursor. Or you could do some math and set the velocity to the length of the block
     
  5. Glassblocks are broken when the arrow (bullet) hits it. As you can see the arrow actually hits the glass because I'm looking at it. However, visually it looks like the arrow is going to the left when its not.
     
  6. Really weird try decreasing the velocity then tell us
     
  7. This is a minecafters issue. It's the same with snowballs.
     
    • Agree Agree x 1
  8. If projectile goes faster than 4.0F then it will make curve either to left or right, but it is only visual so projectile actually goes straight.
     
  9. I know, but I've seen servers that managed to make fast bullets so I'm wondering how they did it.
     
    #9 SmokingIsBadMkay, Apr 21, 2017
    Last edited: Apr 21, 2017
  10. NathanWolf

    Supporter

    Were they not using arrows?
     
  11. I'm 99% sure they are using arrows.
     
  12. NathanWolf

    Supporter

    Seems unlikely since the weird behavior looks to be a client problem... Maybe let us know what server it was, or if you have a video.
     
  13. Pretty sure they don't. Take for example hypixel. They just draw a line of particles and get the line of sight etc.
     
  14. BananaPuncher714

    Supporter

    No, I'm pretty sure they use fireworks and simply push them in a certain direction, like in Quake.
     
  15. NathanWolf

    Supporter

    I'm pretty sure Quake doesn't use fireworks :D

    Seriously, though, I don't play Hypixel so have no idea, but I'd imagine they just have their own custom projectiles. It's not that hard and ends up working out much better than trying to make an arrow (or snowball, firework, whatever) behave like a bullet.
     
  16. Was thinking about doing this. I guess this is the best option to make this work.
     
    • Agree Agree x 1