making a gameobject follow the mouse question

I know I have been asking for help alot on the forums lately, but I just cant find out how to do this, I have tried to google it, search the forum, the wiki, the script refference and a lot more

does anyone know how to make a gameobject stay ontop of the mouse at all time???

My gues is to use input.mousePosition as the position for the gameobject, but I’m not realy shure

If you want the game object to match the cursor position exactly, you can use raycasting, Camera.ScreenToWorldPoint(), etc. Keep in mind that the cursor position will in general correspond to an infinite number of points (with varying depths relative to the camera), so you’ll need to impose some additional constraints in order to compute a unique point. (There are other options as well, such as using a GUI control, setting up an orthographic camera with a projection that matches screen space, etc.)

If you need more help than that, perhaps you could tell us a little about the context. What is it that you’re trying to do exactly?

thanks:smile:, but I need more help
What I am trying to do is to make a gameobject (a sphere with some scripts) follow the mouse in both Y and X (I think)

It’s kinda like the controlls in this flashgame:

Thanks for the help, it works now:smile: