Ray Problem

my image, please see

The image shows my race track. It also shows Box A and Box B. The road and the two white boxes are created in blender. They are scaled up to 10x. I use the getWorldTranslation() of Box A and Box B to serve as my origin and direction to my Ray. The ray will served as the finish line. Problem is, it does not work. As you can see the blue box (created in jMonkey ) is in the middle of my finish line, it suppose to turn red when the ray collides with it, but it does not. The blue box will turn red when its too close to the box A. The blue box however does not turn red when too close to the box B.

I tried putting the blue box up, down and side ways of box A to determine if the ray is in the wrong direction, but still the blue box only turns red when too close to the box A, almost colliding it. I think I have a very short ray, but i think this cant happen since the ray’s limit is infinity. Im sorry but Im very confused. Please help me figured this out.

initialize ray in simpleInitApp


startA = map.getStartPos()[0]; // world translation of box a

startB = map.getStartPos()[1]; // world translation of box b

ray = new Ray(startA, startB);


my simpleUpdate

[java] @Override

public void simpleUpdate(float tpf) {


results = new CollisionResults();

System.out.println("ray length: " + ray.getLimit());

boxGeo.collideWith(ray, results);

if(results.size() > 0) {

boxGeo.getMaterial().setColor(“m_Color”, ColorRGBA.Red);

} else

boxGeo.getMaterial().setColor(“m_Color”, ColorRGBA.Blue);



new Ray() have two parameters, origin and direction. You are puting there two positions.

@Alpedar, so i cant use positions to create my ray?? I want my ray from box A to box B.

box A’s position is at 25, 38, -6 and

box B’s position is at 25, 38, 33.

Can you please help me, how should I create my ray… I need it badly. Do you have any ideas? Thank you

problem solved. I should have not use the position of box b.

what i did is used box a’s position as the origin and get it Z rotation column as the direction…