using UnityEngine; using System.Collections; public class KeyboardControls : MonoBehaviour { public float speed = 200; // Use this for initialization void Start () { } // Update is called once per frame void Update () { // Add force, but stop eventually Vector2 acceleration = new Vector2(); acceleration.x = Input.GetAxis( "Horizontal" ) * speed; acceleration.y = Input.GetAxis( "Vertical" ) * speed; //this.gameObject.transform.position = new Vector2( this.gameObject.transform.position.x + acceleration.x, this.gameObject.transform.position.y + acceleration.y ); this.rigidbody2D.AddForce( acceleration ); // Add force if ( Input.GetKeyDown( KeyCode.R ) ) { Application.LoadLevel( Application.loadedLevel ); } } }