Hi again!
Today I wanted to implement my steering behaviour and to see whats in front of my characters I cast a ray in the direction they are heading to see if anything is in their way.
I want to slow the character down if it comes close to an obstacle, and therefore I wanted to get the closest intersection with the ray via
Ray ray = new Ray(psd, direction);
PickResults results = new BoundingPickResults();
results.setCheckDistance(true);
p.getParent().findPick(ray,results);
PickData closest = results.getPickData(0);
The first problem is that the results are not sorted by their distance as stated in the manual and I saw that calling results.getPickData alters the content of results.
Therefore I cant even loop through all the results and find the closest distance by hand since calling results.getPickData changes which result is at which index within the results.
Any thoughts?
Im not using any multithreading that could alter the results why I search through them.
And I also displayed a Line to represent my ray to see if the ray to see if I cast the ray correctly and the line looks just fine.