Plane, Cursor and Ray problem (like "building games&amp

I have got a plane that i want an object to follow and be in the same pos of the mouse. like for example, games that you have to build something, like Age of Empires, Warcraft, The Movies.
I want doesnt mattering the camera’s angle the object to follow the plane (the part inside the camera’s view of course)

The way I thought of doing this is creating a ray at the mouse cursor, or by some how use the one used for internal calculation of the mouse over sensor and get the collision point with my plane. ( for this I can use the Ray.getHitPosition function ) At the position I shall show an object, that when you presses the left mouse button it fixes at the position.
I tried myself do some scripting but I couldn’t get it going, so I need some help.
i am not used to blender functions, though I know python.

Here is an explanatory image

http://img308.imageshack.us/img308/8798/camera5lg.jpg

Regards in advance,
Daniel

PS: wow! that was long :o

Is there a way to create a ray just using python? because I have got the two points of the cursor ray and I need to create another ray so i can set the property of what it collides. Or if someone could tell me a function that sets the property of the ray would help a lot.

Thanks in advance,
Daniel

Can someone give any help? please?

Here’s a thought. Say the camera is always adding an object called “Detect”. When Detect hits an object with property “ground”, then Detect adds the building object (and self-destructs). The object would always be in the middle of the screen and moving the mouse could move the camera.

Thx for your reply!
Good idea. If “Detect” is an object how would you add it so it collides with the plane? maybe a two vertex object, like a line?. I could create a ray sensor of the camera instead the mouse and move the camera instead of the mouse as you said. Good idea! I will experiment with it and post here.

Greetings,
Daniel

Some time ago I wrote a script that does exactly this:

An empty called “Target” is moved to the place of the blue dot in your figure when the mouse is moved.
When you run my blend you will see something moving as you move your mouse. This was my idea of a crosshair :slight_smile: that tracks the “Target”. You can safely remove it.

I hope it’s useful!

Wow! Thats awesome! exactly what I need! :o
You dont know how happy I am! :smiley:
You rule!
You made that script yourself?!?! It’s incredible. Now i am like this > 8) <

Daniel