I'm trying to convert the Vector data from Input.mousePosition() relative to the playing screen. It works without the camera.ScreenToWorldPoint line but not properly. However, it doesn't work at all with that line in, saying I need to a attach a camera (there is one as a child to the player).
Here's my code thus far:
asked Jun 16 '10 at 01:29 AM
If you don't have a camera attached to the Game Object, of course it won't work. "camera" is just a shortcut for GetComponent(Camera), not GetComponentInChildren(Camera). Just add this at the top of the script and drag your camera's Game Object onto it.
Then, change your trouble line to
Call it whatever you like if you don't like "theCamera". I like using C# better for this, because you can still call it "camera", you just need to use
answered Jun 16 '10 at 02:03 AM