Attaching an RTS scrolling script to a camera (Noob Question)


I’m trying to make an RTS game where it is necessary to have a script to rotate the camera left when the mouse touches the left of the screen and right when it touches the right of the screen etc. and also to use the arrow keys to pan and the mouse wheel to zoom in. I have pretty much found the script I need (though improvements to this would be welcome) but my question is, from the main camera, how can I attach this script. I am very early on in the developing and have not touched the camera. Any contributions to the issue are welcome.



uhm. you drag the script onto the camera in your scene’s hierarchy view?

I strongly recommend taking some time to go through some basic introductory tutorials. This kind of question will make you unpopular very quickly around here. There’s official tutorials on the unity site, and there is also an in-depth series of free video tutorials available from Walker Boys Studio. If you’re too impatient to go through the lengthy introductories, just working along through the first two labs will teach you a lot of the very basics of unity - like how to attach scripts to things!

Sounds like you are pretty new to Unity, it’s definately a great engine to work with but there is a learning curve at first. I agree with WillTAtl that you should spend some time searching through the online docs. When I get someone new to unity working with me, I have them start with small projects, such as moving a camera, a block, or something like that and ask that they find the answer in the docs. Even down the line when you are used to the engine, you’ll find yourself looking up functions and things in there all the time. As for hooking scripts on to the camera, you have to get yourself into the object/component mindset. Unity is built heavily around creating game objects and hooking components to them. You could say that your camera is a game object, and the script you want to add is a component. Every game object will start with a transform component which will show up in the inspector. To add the script, you drop it in there.

Thanks a lot. The script works brilliantly, I’ll have a look at the tutorials as per your advice.