Skip to content

Instantly share code, notes, and snippets.

@ted80
Created July 10, 2016 17:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ted80/849876c928e2339f5f72b5e1c3c79540 to your computer and use it in GitHub Desktop.
Save ted80/849876c928e2339f5f72b5e1c3c79540 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class CameraMovement : MonoBehaviour
{
[Range(0.2f, 4f)]
public float speed = 1f;
void Update ()
{
if(Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
{
gameObject.transform.position += -(gameObject.transform.right * speed * 12f * Time.deltaTime);
}
if(Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
{
gameObject.transform.position += (gameObject.transform.right * speed * 12f * Time.deltaTime);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment