Is there some problem with rayCast()?

I’m getting the distance between two objects by getting the hit point (second thing returned) and subtracting the ‘from’ object’s position.

It’s giving me nonsense results. I then sat down and tested it and found that it worked fine if the ray cast hit an obstacle dead on (ie, normal to a face) but changing the angle by as much as 5 degrees caused the ray to travel straight through and return None.

I tried a range of different physics settings (triangle mesh, convex hull, randomly changing the ‘margin’ and ‘radius’ values) without any idea what any of them meant.

What gives? I’m actually behind on a deadline and really beginning to regret having used blender. Is this a bug or is there anything I can do about it?

What is the code you are using, it’s not the hit position going out of range of what you set the ray to, is it?

Also, if you want to have a helpful guide to debugging, you can always try to create a debug object that is placed at the hitPosition of the ray.

If you’re still stumped, could you upload a simple .blend outlining the problem? I can’t recall ever having an issue such as yours.

You could always enable Show Physics Visualization in the Game menu which will draw the bounds for all game objects, helping you to determine if the ray is missing the bounds of the object.

Starting a new blend from scratch works perfectly, I’m using Ace’s suggestion of a debug object just to sure. But I tried exactly the same thing in the old blend and it wasn’t picking up.

Since time is running out and the old blend was mostly dross, I’m going to start from the new blend and hope the same thing doesn’t happen again.

Cheers for your help, both of you. (I tried Show Physics Viz, but without knowing what the different colours mean and what algorithms are behind them, it was rather useless to me.)

As far as I know:
green are the face boundaries (of static meshes)
red represent the margin cage (bounding box)
white represents the dynamic bounding type (which can become green after deactivation)

I remember there was yellow = face normals. But it looks like they are hidden in 2.65

Rays are not visible

Thanks, Monster.

The thing about documentation is that the people who need it can’t do anything about it, and the people who can are the people who don’t notice the lack of it.