Raycasting from other places other than the center?

For raycasting I’m using this, and works wonderfully:


mainChar = cont.owner

print(mainChar.rayCastTo([mainChar.worldPosition.x, mainChar.worldPosition.y+2.1, mainChar.worldPosition.z], 2.1))

I’m happy and at peace. My cube collides and the console prints out the name of the object hit. I find solace imagining the fall of worlds under my mighty nostrils. It’s rather inspiring.

Now, I’d like to shoot a few more rays but in other more strategic positions so i can fine tune the penalties when collision with dangerous objects happen among other stuff.

Of course, being the most advanced simulator ever produced by a being barely capable of lift a bag of potatoes, you can touch the said dangerous objects from the top, but if you ram them… Penalty will take place.

Now, is there a way to set the origin point of a ray or should I use a dummy object to use as an origin for the rays?
Of course, using basic maths to find distance is ok, but if there’s a function built-in, I’m better off using it.

You can use the rayCast() function to cast a ray with more options that rayCastTo() offers, one of them being the start of the ray cast’s position.

For distance, there’s the getDistanceTo() function.