using System.Collections; using System.Collections.Generic; using UnityEngine; public class script1 : MonoBehaviour { float speed1=15.0f; Rigidbody2D ufo1; // Start is called before the first frame update void Start() { ufo1 = GameObject.Find("UFO").GetComponent(); } // Update is called once per frame void Update() { if(Input.GetKey("up") || Input.GetKey("down") || Input.GetKey("left") || Input.GetKey("right")) { float x1 = Input.GetAxis("Horizontal"); float y1 = Input.GetAxis("Vertical"); Vector2 movement = new Vector2(x1,y1); ufo1.AddForce(movement * speed1); //ufo1.velocity = movement * speed1; } else { ufo1.velocity = new Vector2(0,0); } } }