Jump to content

Checking distance between two positions?


Recommended Posts

Posted

position.distance() will not work properly if you want accurate long distance checks because that's just an application of Pythagora's algorithm and does not take into account plane difference, links or obstacles at all.

 

map.realDistance(Position position) should take into consideration all the above situations. You could also try walking.webWalk(Position... positions) as that walks to the closest of the given positions since you mentioned you only want to walk. 

  • Like 1
Posted

position.distance() will not work properly if you want accurate long distance checks because that's just an application of Pythagora's algorithm and does not take into account plane difference, links or obstacles at all.

 

map.realDistance(Position position) should take into consideration all the above situations. You could also try walking.webWalk(Position... positions) as that walks to the closest of the given positions since you mentioned you only want to walk. 

 

However realdistance seems to be off a lot.

I tried using it to find the real closest goblin (like one next to you but behind the fence would actually be further away to run to it)

However it mostly doesn't seem to actually pick the closest one, it looked fairly random

Posted

However realdistance seems to be off a lot.

I tried using it to find the real closest goblin (like one next to you but behind the fence would actually be further away to run to it)

However it mostly doesn't seem to actually pick the closest one, it looked fairly random

It seems to be working fine for me but I haven't tested it much. If you don't trust OSBot's realDistance() method you can try implementing A* with collision flags and getting the length of the path and you should get the same result.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...