Change snowball range

Discussion in 'Programming' started by Gomze, May 27, 2017.

  1. ^topic
    Thought about:

    Code (Text):
    Snowball snowball = e.getPlayer().launchProjectile(Snowball.class);

    Vector velocity = (e.getPlayer().getLocation().toVector().subtract(snowball.getLocation().toVector()).normalize()).multiply(1);
                    snowball.setVelocity(velocity);
     
  2. Code (Java):
    Snowball snowball = e.getPlayer().launchProjectile(Snowball.class);

    Vector velocity = snowball.getVelocity().multiply(2);
    snowball.setVelocity(velocity);
    is a lot shorter. The 2 is a placeholder - 1 won't change anything, anything less than 1 (eg. 0.5) will make the ranger smaller, anything larger than 1 will make the range bigger.