using UnityEngine;
using System.Collections;
public class cube : MonoBehaviour
{
public float moveSpeed;
private Rigidbody rb;
public float JumpHeight = 0.5f;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();
rb.freezeRotation = true;
moveSpeed = 1f;
}
void Update()
{
transform.Translate(moveSpeed*Input.GetAxis("Horizontal")*Time.deltaTime,0f,moveSpeed*Input.GetAxis("Vertical")*Time.deltaTime);
//jump
if (Input.GetKeyDown(KeyCode.Space))
{
rb.AddForce(transform.up * 40000 * JumpHeight * Time.deltaTime);
}
}
}