using System.Collections; using System.Collections.Generic; using UnityEngine; public class SphereControl : MonoBehaviour { public Rigidbody rigidbody; [Range(0.01f, 10.0f)] public float speed = 1.0f; [Range(0.01f, 1000.0f)] public float jumpForce = 200.0f; // Update is called once per frame void Update() { if (Input.GetKey(KeyCode.RightArrow)) { rigidbody.AddForce(speed, 0, 0); } if (Input.GetKey(KeyCode.LeftArrow)) { rigidbody.AddForce(-speed, 0, 0); } if (Input.GetKey(KeyCode.UpArrow)) { rigidbody.AddForce(0, 0, speed); } if (Input.GetKey(KeyCode.DownArrow)) { rigidbody.AddForce(0, 0, -speed); } if (Input.GetKeyDown(KeyCode.Space)) { rigidbody.AddForce(0, jumpForce, 0); } } }