I am making a Cube tracking to the cursor. and I would like to get the position of the cube.
In the game I switch to Camera view. the camera is excatly on the top of the cube,and it face to the -z axis(Rotation: 0,0,0)
then i use python script to print the position of raySource, I found when i change the ‘clipping’ property of the camera the position on z axis also changed.
I just want to know how the Clipping affect to the raySource?
There are what i have done in my game,
I add a Mouse sensor and an always sensor to a Cube and use following codes to get and print the RaySource attribution of it.
co=bge.logic.getCurrentController()
cube=co.owner
mousePos=co.sensors['MousePos'] # the name of the Mose sensor
mpos=mousePos.raySource
cube.position=mpos
print(mops)
tags when posting python code. Otherwise it is useless.
I would say: For a mouse over it makes sense. There is no need to cast the ray outside the viewing frustum. That would detect objects you can't see which is usually not what a user expects.
Monster
I would imagine if you cast a ray from the camera to the clipping plane, the intersection point is where you’d find your raySource. I can’t test that right now though, so don’t take my word for it.
The difference to a normal ray is that the raySource is not at the cameras origin, but the near clipping plane and the rayTarget ends at the far clipping plane.