Solved Knock back a player in opposite direction to a location

Discussion in 'Plugin Development' started by PePsiGam3r, Sep 18, 2014.

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

    PePsiGam3r

    Hey Bukkit, I'm trying to make a plugin contains a squared distance protection so when someone go into any of them it'll be knock the player back.
    I tried this
    Code:java
    1. p.setVelocity(p.getLocation().getDirection().multiply(-1.0D));

    , but it knock back the player in opposite of themselves direction, not the location they have entered.
    Help please?
     
  2. Offline

    GeorgeeeHD

    PePsiGam3r
    Code:java
    1. Location loc = originLocation; // The location that is the source of where to knock them back.
    2. Vector v = player.getLocation().toVector().subtract(loc.toVector).normalize(); // Create the vector.
    3. p.setVelocity(v); // Set the velocity.
     
  3. Offline

    PePsiGam3r

    GeorgeeeHD What I need is getting the location of where to knock them back.
    I have the location of where they entered only.

    GeorgeeeHD Never mind, fixed it.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
Thread Status:
Not open for further replies.

Share This Page