[SOLVED]Building line of sight for my AI, collision with environment issue

I’m using ray casting to trace collisions with a line of sight from my AI to track geometry in front of the AI, I just plan to pinpoint the co-ordinates of what is in front of them.



However I’m having trouble getting the co-ordinates from

[java]

ray.collideWith(sceneModel, results);[/java]



Just a few bits of the code:

[java]

Spatial sceneModel;

CollisionShape sceneShape = CollisionShapeFactory.createMeshShape((Node) sceneModel);

landscape = new RigidBodyControl(sceneShape, 0);

sceneModel.addControl(landscape);

[/java]



I’m returned a com.jme3.collision.UnsupportedCollisionException and from the little that I’ve read - I imagine ray is counted as a complex shape.

Is there a better way to do what I’m trying to do?

You mix up bullet collision and geometry collision here. Check the HelloPicking and HelloCollision tutorials again.

Ahh! I see, seeing more use for the nodes now :slight_smile:



Thanks

Sorry, double post but didn’t think it needed a new topic.



Is there any way to render a ray on screen?

Not really, you can use the “Arrow” debug shape mesh and put a geometry where the ray is to make it visible.

Cheers, works out for what I want.