Knock players away from player

Discussion in 'Plugin Development' started by HamOmlet, Aug 14, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    HamOmlet

    I'm a little unsure as to how I would knock players away from another player. I was thinking of simply adding an XYZ value like so:
    Code:
    final Vector direction = player.getLocation().add(x, y, z);
    I'm not trying to knock the players in a particular direction - just away from the player.
     
  2. Offline

    number1_Master

    You have to change their velocity or something like that. I think it is player.setVelocity(), but I'm not sure.
     
  3. Offline

    JjPwN1

    Code:
                        Vector dir = player.getLocation().getDirection();
                        Vector vec = new Vector(dir.getZ() * .5D, .5D, dir.getX() * .5D);
                        player.setVelocity(vec);
    Change that to how you'd like. I took this from my "BbySlap" plugin.
     
  4. Offline

    HamOmlet

    Works beautifully! Much thanks. ;)

    By any chance, are you checking for distance between players? I'm looking to increase the amount depending on the distance between both players.
     
  5. Offline

    JjPwN1

    No, I am not. And am unsure on how to do so. But I can assume you can try using
    Code:
    player.getNearbyEntities()
    In some way.
     
Thread Status:
Not open for further replies.

Share This Page