Camera Point and click Movement

I’m fairly new to Unity, so I’m just getting used to its controls,as I’m familiar with other 3D game making engines. I was wondering what a javascipt about moving the camera with the arrow keys would look like. The camera would move back and forth and up and down, and it would NOT rotate or zoom in/out. Please help.

Well, try this:

function Update() {
     transform.Rotate(0, Input.GetAxis("Horizontal")/3, 0);
     transform.Translate(Vector3.forward * Input.GetAxis("Vertical")/10);    
}

To move it forward, simply use this:

// Move the object forward along its z axis 1 unit/second.
transform.Translate(Vector3.forward * Time.deltaTime);

To move it any other direction, simply modify the vector. You can use Vector3.forward (Forward), Vector3.forward * -1 (Backwards), Vector3.right (Right), and Vector3.right * -1 (Left).

You can also multiply the vector by a fraction to make it slower, or by a number greater than one to make the movement faster.

For more information, check out this site.

Those are both good ways of moving around in the awesome world of Unity! :slight_smile:

but there is also another way to move players, this way is only if you want a “GameInput” script kind of movement type:

function Update()
{

//using Input to get keycodes is a neat option, which i always use

if(Input.GetKey(KeyCode.W))
{

    //GetKey returns true if the key is held down.

}

if(Input.GetKeyDown(KeyCode.W))
{

    //GetKeyDown returns true if the user pressed the key down during this frame.

}

if(Input.GetKeyUp(KeyCode.W))
{

    //GetKeyUp returns true if the user pressed the key down during this frame.

}

}

When you use this make sure you check out unity scripting reference for KeyCode :wink:

Have a nice time scripting.