RTS Camera Script from following:

Hey, all, not a noob to Unity anymore, but like most, I try to stay as far from programming as possible (I know, it’s actually a bad thing to want to) but I’m trying to get the script for an RTS style camera to work as according to the thread:

but being oblivious to a lot of programming - I’d like some elaboration from that script, maybe even to centralize it for newbies like myself.

As the person says in that thread - variables have to be defined. Variables like what? In the script, what would “myTransform” be? The actual camera object that the script would be attached to? As in, for instance the “//Do camera movement by keyboard” section would be “MainCamera.Translate…etc etc”?

As a disclaimer, be clear that I’m not asking how to program as I wouldn’t waste the community’s time like that, but logic with THAT script specifically. I promise I will make everyone one hell of an RTS!

For reference:

var mPosX = Input.mousePosition.x;
var mPosY = Input.mousePosition.y;

// Do camera movement by mouse position
if (mPosX < scrollArea) {myTransform.Translate(Vector3.right * -scrollSpeed * Time.deltaTime);}
if (mPosX >= Screen.width-scrollArea) {myTransform.Translate(Vector3.right * scrollSpeed * Time.deltaTime);}
if (mPosY < scrollArea) {myTransform.Translate(Vector3.up * -scrollSpeed * Time.deltaTime);}
if (mPosY >= Screen.height-scrollArea) {myTransform.Translate(Vector3.up * scrollSpeed * Time.deltaTime);}

// Do camera movement by keyboard
myTransform.Translate(Vector3(Input.GetAxis("EditorHorizontal") * scrollSpeed * Time.deltaTime,
                              Input.GetAxis("EditorVertical") * scrollSpeed * Time.deltaTime, 0) );

// Do camera movement by holding down option                 or middle mouse button and then moving mouse
if ( (Input.GetKey("left alt") || Input.GetKey("right alt")) || Input.GetMouseButton(2) ) {
    myTransform.Translate(-Vector3(Input.GetAxis("Mouse X")*dragSpeed, Input.GetAxis("Mouse Y")*dragSpeed, 0) );
}

The variables that have to be defined in that script are any words that aren’t key words/functions in UnityScript.

The ones I see, taking a glance, are myTransform, scrollArea, scrollSpeed, dragSpeed, mPosX, and mPosY.

The latter two are defined at the top of the script. Everything else is something you have to provide reference to either by drag/dropping the appropriate component in the editor or typing in values. Your assumption about myTransform is correct; it is supposed to be the reference to the camera’s transform.