UnityScripterAI
Discord ↗
Link Copied to Clipboard
×
"create a cube and make it fall"
using UnityEngine; public class FallingCube : MonoBehaviour { public GameObject cubePrefab; private GameObject cubeInstance; // Start is called before the first frame update void Start() { // Instantiate the cube cubeInstance = Instantiate(cubePrefab, new Vector3(0, 10, 0), Quaternion.identity); // Add a Rigidbody component to the cube to make it fall Rigidbody rb = cubeInstance.AddComponent<Rigidbody>(); } }