gdx-ai
gdx-ai copied to clipboard
Calculate distance between steerables in a 2D wrapped around environment
Imagine our characters is moving on the surface of a sphere. So there will be 2 ways to calculate distance between them. But all of gdx-ai behaviors use owner.getPosition() to calculate distance.
I think Steerable interface should have getDistance(point:Vector2):float getDistanceSq(point:Vector2):float method and behaviors will use them to decide how to seek, evade, flee...
Hmmm... Shouldn't something like
toTarget.set(target.getPosition()).sub(owner.getPosition());
be affected too?
and getDistance(agent:Steerable):float, getDistanceSq(agent:Steerable):float
or getToTargetVector(agent:Steerable, agent:Steerable):Vector2, maybe
At a first glance I'd say that toTarget should be an instance of a class that extends Vector2 and overrides the appropriate methods.
But currently there's no way to set vectors internally used by behaviors.