getRayTarget problems

Im trying to use the mouse arrow to set the position of an empty (called ‘target’) in my simulation scene.
What Im doing:

  1. The following script is attached to a mouseover senesor on my object where I want the target empty to snap to.

GameLogic.target_pos = GameLogic.getCurrentController().getSensor(“mouse_ovr”).getRayTarget()

  1. The script below is attached to the ‘target’ empty which is supposed to snap to where the mouse is pointing.

GameLogic.getCurrentController().getOwner().setPosition(GameLogic…target _pos)

The problem:
The target empty does move but not to the exact position of the mouse. The camera that I am using is not fixed or looking down. It moves in a spherical motion - I think that this is the problem.
The getRayTarget() method works but sends [x,y,z] coordinates that don’t accurately relate to the position of where the hypothetical mouse ray is hitting.

If anyone has a solution I’d be very thankful.

Check your syntax, “Pos ition” is not the same thing as “Position” same goes for “GameLogic…whatever”, mind the dots, there should not be two right after the other like that.

Are you getting any console errors?

Post the .blend, so that we can see the problem exactly.

PS: I think the mouse has to be hitting something in order to return a position back.

yeah I think these rays can report what normal they hit but that’s about as accurate as they get

Use getHitPosition()