Stormscythe 263 Share Posted March 9, 2015 (edited) Hello I am trying to get the position of gameobjects, so I could walk to them - how do I do this? This is how I would think it worked: getWalking.walk(object.getLocation()); Edited March 9, 2015 by jannikl Link to comment Share on other sites More sharing options...
Chris 154 Share Posted March 9, 2015 Hello I am trying to get the position of gameobjects, so I could walk to them - how do I do this? This is how I would think it worked: getWalking.walk(object.getLocation()); You're looking for GameObject#getTile() http://dreambot.org/javadocs/org/dreambot/api/methods/walking/impl/Walking.html#walk-org.dreambot.api.methods.map.Tile- Link to comment Share on other sites More sharing options...
Stormscythe 263 Author Share Posted March 9, 2015 You're looking for GameObject#getTile() http://dreambot.org/javadocs/org/dreambot/api/methods/walking/impl/Walking.html#walk-org.dreambot.api.methods.map.Tile- Thanks Chris While I have you, is there a way to check which of the 4 different gameobjects in an array, that are closer to you? Link to comment Share on other sites More sharing options...
Nuclear Nezz 1995 Share Posted March 9, 2015 Thanks Chris While I have you, is there a way to check which of the 4 different gameobjects in an array, that are closer to you? You'd have to loop through the array and check the distance of each gameobject to you, and return the one that is closest. You can check distance with gameObject.getTile().distance(getLocalPlayer().getTile()) Link to comment Share on other sites More sharing options...
Stormscythe 263 Author Share Posted March 9, 2015 (edited) You'd have to loop through the array and check the distance of each gameobject to you, and return the one that is closest. You can check distance with gameObject.getTile().distance(getLocalPlayer().getTile()) Thanks Nezz, but it appears to throw an error: Cannot convert from double to boolean EDIT: Ah, got it to work eventually, thank you :-D Although, I have another question (lol) - How would I return the object closest to me? Edited March 9, 2015 by jannikl Link to comment Share on other sites More sharing options...
Chris 154 Share Posted March 9, 2015 Thanks Nezz, but it appears to throw an error: Cannot convert from double to boolean EDIT: Ah, got it to work eventually, thank you :-D Although, I have another question (lol) - How would I return the object closest to me? You can use the method GameObjects#closest(Filter<GameObject> f) http://dreambot.org/javadocs/org/dreambot/api/methods/interactive/GameObjects.html#closest-org.dreambot.api.methods.filter.Filter- http://dreambot.org/javadocs/org/dreambot/api/methods/filter/impl/NameFilter.html Link to comment Share on other sites More sharing options...
Stormscythe 263 Author Share Posted March 9, 2015 You can use the method GameObjects#closest(Filter<GameObject> f) http://dreambot.org/javadocs/org/dreambot/api/methods/interactive/GameObjects.html#closest-org.dreambot.api.methods.filter.Filter- http://dreambot.org/javadocs/org/dreambot/api/methods/filter/impl/NameFilter.html Hello - that doesn't seem to work, when the GameObjects I declared are in an array. Link to comment Share on other sites More sharing options...
Chris 154 Share Posted March 9, 2015 Hello - that doesn't seem to work, when the GameObjects I declared are in an array.You can manually do it then private GameObject getClosestGameObjectFromList(List<GameObject> gameObjectList) { double distance = 100D; GameObject closestObject = null; for (GameOject temp : gameObjectList) { if (temp != null && temp.distance(getMyPlayer().getTile()) < distance) { distance = temp.distance(getMyPlayer().getTile()); closestObject = temp; if (distance <= 1) break; } } return closestObject; } This is untested. Link to comment Share on other sites More sharing options...
Recommended Posts