Solved move snowball

Discussion in 'Plugin Development' started by lavatheif, Nov 12, 2016.

Thread Status:
Not open for further replies.
  1. is there a way to move a snowball forward after spawning it in?

    Snowball s = p.getWorld().spawn(p.getLocation(), Snowball.class);
    s.getLocation().setYaw(p.getLocation().getYaw());
    s.getLocation().setPitch(p.getLocation().getPitch());

    is how im spawning it btw.
     
  2. Offline

    ZP18

    First of all please put your code in the CODE tags. To make the snowball move you have to give it a velocity.
     
    DonDays likes this.
  3. i tryed that but it just moves in one direction
     
  4. Offline

    ZP18

    How can a snowball move in more than one direction? It isn't multiple items...
     
  5. i mean like
    Code:
    s.setVelocity(new Vector(0, 0, 5));
    moves it in one direction along the z axis and not whatever direction its facing
     
  6. Offline

    ZP18

    Search up some tutorials on using vectors
     
  7. Offline

    timtower Administrator Administrator Moderator

    @lavatheif Get the orientation of the players head (so where he is looking)
    Multiply by something.
    use setVelocity with that as parameter.
    Vectors are absolute, not relative to the players
     
    AL_1 likes this.
  8. Offline

    Zombie_Striker

    @lavatheif
    I just want to remind everyone that there is already a "Player#launchProjectile()" method that manages all this for you. Just set the type <T> equal to the SnowBall.class and that's it. If you then want to make the snowball faster, all you need to do is multiply the existing velocity by a scalar and reset the velocity.
     
Thread Status:
Not open for further replies.

Share This Page