RayCasting vs vertex3f for navigating

Hi i was considering use ray cast forward every time i move my object to see if it get to hit any one in front of it.
But then i’ve considere as well using worldTranslation,if i know my size and future location all i need is check if it equals other objects location + their size. Soo what i would to know is how mutch rayCast consuming in front of
lets say :

doing same for Z and not doing for Y couse my objects cant fly or stuff. And doing this for each Other object exists in world.

Or should i just ray cast for node with all object in the world. I know its not a perfect code :smiley: but its just to get an idea on what i want to use at place of ray ,if it is cheaper for pc efforts .

And im fine with vertex giving not precise data and is good only for a ball :slight_smile: may be ,but im fine with let it leav some extra space for just in case :slight_smile:

Soo what do you think is better ray or vertex using ?

1 Like

That seems like a lot of code to basically check the distance between two objects.

1 Like

Can’t you just do

if(a.getWorldTranslation().distance(b.getWorldTranslation()) > movingObjectSize/2+otherObjectSize/2) {


However, if you have more complicated shapes than spheres you should probably use Rays. You can use rays efficiently by only checking collisions in a certain Node (i.e. if you ray the rootNode, it will check more things than if you’d ray a node with less children).


Do u think it will still be a cheapest solution then ray if i do

 if(a.getWorldTranslation().add(Vector3f(distance in direction it will go)).distance(b.getWorldTranslation()) > movingObjectSize/2+otherObjectSize/2) {

couse i actually need to know if he will hit it when he is there more then,where he is now