gdx-ai icon indicating copy to clipboard operation
gdx-ai copied to clipboard

Calculate distance between steerables in a 2D wrapped around environment

Open implicit-invocation opened this issue 10 years ago • 3 comments
trafficstars

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...

implicit-invocation avatar Jul 14 '15 12:07 implicit-invocation

Hmmm... Shouldn't something like

toTarget.set(target.getPosition()).sub(owner.getPosition());

be affected too?

davebaol avatar Jul 14 '15 13:07 davebaol

and getDistance(agent:Steerable):float, getDistanceSq(agent:Steerable):float or getToTargetVector(agent:Steerable, agent:Steerable):Vector2, maybe

implicit-invocation avatar Jul 14 '15 13:07 implicit-invocation

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.

davebaol avatar Jul 14 '15 13:07 davebaol