Xephy 237 Share Posted December 22, 2016 I'm not sure how to check to see if there's another player within a certain distance of your character. Any help? Link to comment Share on other sites More sharing options...
LogicSoup 92 Share Posted December 22, 2016 Player and Character API Loop through the available players then use the #distance() method? I'm not sure how to check to see if there's another player within a certain distance of your character. Any help? Link to comment Share on other sites More sharing options...
Pandemic 2675 Share Posted December 22, 2016 if (getPlayers().closest(p -> p != null && !p.equals(getLocalPlayer()) && p.distance() < 5) != null) { //If there's a player within 5 tiles of my player //... } I'm not sure if the equals check is needed, but it might be Link to comment Share on other sites More sharing options...
Xephy 237 Author Share Posted December 22, 2016 if (getPlayers().closest(p -> p != null && !p.equals(getLocalPlayer()) && p.distance() < 5) != null) { //If there's a player within 5 tiles of my player //... } I'm not sure if the equals check is needed, but it might be Always coming to the rescue, thanks Pandemic. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.