Get Ray distance to unknow point

Hi :yes:
I want to get distance from camera to unknow point (not center object) but on static surfaces.
Something likes this:
http://oi58.tinypic.com/s3oi29.jpg

I was looking for this in API but I found only which can use to before defined object (center).
Thx for any tips.

You would need to have a ray pointing out from the camera (straight forward is preferable) if it needs to be at an obscure angle then you may try making an empty that shoots the ray and parent that empty to the camera. You would then use the ray sensor’s “hitPosition” attribute in combination with the KX_GameObject.getDistanceTo() Function. So your end script(running on the camera) may look somthing like this:

from bge import logic
controller = logic.getCurrentController()
own = controller.owner


ray = controller.sensors['Ray']


if ray.positive:
    hitPosition = ray.hitPosition
    distance = own.getDistanceTo(hitPosition)
    
    print(distance)

You can find these thing in the API here:
raySensor.hitPosition
KX_GameObject.getDistanceTo(other)

You rock Kendrick !! Thanks a lot. It’s exactly what I want :smiley:

You can find these thing in the API here:
raySensor.hitPosition
KX_GameObject.getDistanceTo(other)

.hitPosition is even nice :wink:

The topic can be closed.

Just a heads up, if you edit the first post you can change the prefix to [solved] and it’ll mark the thread as such.