How to make a cube move in unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour
{
Rigidbody rb;
Vector3 Vec;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
if(Input.GetKeyDown(KeyCode.Space))
{
rb.AddForce(Vector3.up * 500f);
}
Vec = transform.localPosition;
Vec.y += Input.GetAxis("Jump") * Time.deltaTime * 20;
Vec.x += Input.GetAxis("Horizontal") * Time.deltaTime * 20;
Vec.z += Input.GetAxis("Vertical") * Time.deltaTime * 20;
transform.localPosition = Vec;
}
}