using UnityEngine;
public class SandboxScene : MonoBehaviour
{
public GameObject cubePrefab;
public GameObject spherePrefab;
void Start()
{
Debug.Log("Sandbox scene initialized!");
GameObject cube = Instantiate(cubePrefab, new Vector3(0, 1, 0), Quaternion.identity);
cube.AddComponent<Rigidbody>();
GameObject sphere = Instantiate(spherePrefab, new Vector3(2, 1, 0), Quaternion.identity);
sphere.AddComponent<Rigidbody>();
GameObject ground = GameObject.CreatePrimitive(PrimitiveType.Plane);
ground.transform.position = new Vector3(0, 0, 0);
ground.transform.localScale = new Vector3(5, 1, 5);
ground.AddComponent<BoxCollider>();
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
foreach (Rigidbody rb in FindObjectsOfType<Rigidbody>())
{
rb.AddForce(Vector3.up * 300f);
}
}
}
}
UNITY
Visit unity.com