Context: I want an actor to move away from another approaching actor
The first place you should always look when you ask "how do I" is in the documentation of the related class(es). Whose behavior are you trying to modify? -- an actors; look in the Actor class API to see what method(s) might be useful in applying the wanted behavior. If you find method that might come in handy, take a look at what type value or object it returns. It may lead you on a bit of a trail, looking at the documentation of the class of the returned type to find another method. For instance, you were just working with image height of an actor -- getImage , an Actor instance method, returns a GreenfootImage object and getHeight is a GreenfootImage instance method that returns an int value.
I found a getNeighbours and getObjectsInRange, but I don't quite understand how do I use it, the explanation in the documentation is confusing...
The neighbors one is more suited to grid worlds -- not what you want. In fact, you even used the word "range" in the title of this thread. That was a clue. See what you can do with the objects in range one. Btw, did you see what type value or object it returns?
It returns a list of actors in the radius given but it doesn't return the distance between them
You supply the given distance -- that "certain range" you wanted (see title of this thread). But, how can a List object help? -- look at its API documentation to see what List instance methods are available and might help.
if this is how to detect the actor:
<< Code Omitted >>
but how do I detect which direction the actor came from then since the list doesn't give me the information of where the actor came from?
There will always be a List object returned -- it will never be null; but, it can be empty (or, equivalently, have a size of zero). If the list is not empty, then a Taihei object is in range; however, 3 is a very small range -- you probably want something more in the hundreds. You can get a reference to a Taihei object in the list and get its location using getX and getY on that reference. You can then use turnToward and turn(180) to turn away from said Taihei object.