using System.Collections; using System.Collections.Generic; using UnityEngine; public class Controls : MonoBehaviour { public GameObject control; private int separation = 8; private Vector3 position = new Vector3(0, 10, 0); // Update is called once per frame void Update() { if (Input.GetKeyUp("a")) { if (this.position.x > -1) { this.position.x = this.position.x - this.separation; } } if (Input.GetKeyUp("d")) { if (this.position.x < 1) { this.position.x = this.position.x + this.separation; } } } void FixedUpdate() { this.control.transform.position = this.position; } }