[SOLVED] Collision Results not working properly

Hi everyone.

I have a planet in which there are some agents going around (pursuers and evaders), and I want to check when the lines that connect them to each other intersect with the planet (a very basic field of sight just to get the idea)
My problem is that sometimes the collision results is of size 0 even though it clearly collides with the planet (look screenshot below, sorry for the quality, you should still be able to see the blue line).

screenshot

That is the part of code

       Ray ray = new Ray(nodeAgent.getWorldTranslation(),escaper.getNodeAgent().getWorldTranslation());

       CollisionResults results = new CollisionResults();
       planet.getPlanet().collideWith(ray, results);
        
  
        if (results.size()<=0) {
         //Draw the line
                 
        }

planet.getPlanet() return the Geometry class of the planet.
100% sure it works because I use it in other collisions and it works just fine.

And I use the same vectors that I use in the ray to draw the line. (so same start and same end)

Am I missing something?

The problem is Ray take 2 vectors as the line you draw except line take 2 position vectors whereas ray take one position vector (origin) and a direction vector pointing to your second location =>

Ray ray = new Ray( nodeAgent.getWorldTranslation(), escaper.getNodeAgent().getWorldTranslation().substract(nodeAgent.getWorldTranslation()).normaliseLocal());

1 Like

Oh I see, that indeed worked. Thanks a lot!