This script does not work right for me. For some reason, the movement is not permanent, but it is done only once when the specified buttons are pressed.
The object moves a short distance once and does not move any more until I press the button again.
public class CameraMovement : MonoBehaviour {
public float speed;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.W))
{
transform.Translate(Vector3.forward * speed * Time.deltaTime);
}
if (Input.GetKeyDown(KeyCode.S))
{
transform.Translate(-Vector3.forward * speed * Time.deltaTime);
}
if (Input.GetKeyDown(KeyCode.A))
{
transform.Translate(-Vector3.right * speed * Time.deltaTime);
}
if (Input.GetKeyDown(KeyCode.D))
{
transform.Translate(Vector3.right * speed * Time.deltaTime);
}
}
}