Danger: Python code! There is no visible fancy thing to see when running the file.
The RayCaster provides a wrapper around castRay.
It is much more clean then the existing implementation:
A) it is independent from a KX_GameObject
B) it avoids the confusion with all the optional parameters
C) the result of a cast (PH_RayHit) is much better to understand
example:
import bge
import rayWrapper
...
def demoCast():
ray = bge.physics.createRay([0,0,0], [0,2,0])
ray.includePolygon = True
...
hit = ray.cast()
hitObject = hit.object
hitMaterial = hit.polygon.material
...
This is a first draft. So version is 0.1.
Attachments
rayCaster.blend (358 KB)