I just got access to Codex today and have already spent most of it just toying around with its capabilities. My favorite of which I have found so far is using it to help create Unity scripts.
I decided to try and write a basic brick breaker game using only the output from codex in its “Edit” mode. I wish I kept better track of each command and will next time but honestly was too excited each time I saw it generate useable code. For now though all I have left is the final outputs of each file and a demo video.
The basic methodlogy I used was to create a c# script the standard way, paste the entire thing into the edit mode playground, and then give commands from there. I would like to try and get some form of in IDE solution running, but even just using codex this was was a wonderful experience to see its potential.
All assets were just basic unity primitives.
Video: Demo Video
Scripts:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Brick : MonoBehaviour
{
private void Start()
{
if (GetComponent<BoxCollider>() == null)
{
gameObject.AddComponent<BoxCollider>();
}
}
void OnCollisionEnter(Collision other)
{
Destroy(gameObject);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BrickWallGenerator : MonoBehaviour
{
[SerializeField]
private GameObject Brick;
[SerializeField]
private float Width;
[SerializeField]
private float Height;
// Start is called before the first frame update
void Start()
{
for (int i = 0; i < Height; i++)
{
for (int j = 0; j < Width; j++)
{
GameObject brick = Instantiate(Brick, new Vector3(j, i * 0.5f, 0), Quaternion.identity);
brick.transform.parent = this.transform;
}
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Paddle : MonoBehaviour
{
public float Speed = 10f;
// Update is called once per frame
void Update()
{
if (Input.GetKey(KeyCode.LeftArrow))
{
transform.position += new Vector3(-Speed * Time.deltaTime, 0, 0);
}
else if (Input.GetKey(KeyCode.RightArrow))
{
transform.position += new Vector3(Speed * Time.deltaTime, 0, 0);
}
transform.position = new Vector3(Mathf.Clamp(transform.position.x, 0, 9.5f), transform.position.y, transform.position.z);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BreakerBall : MonoBehaviour
{
Rigidbody rb;
[SerializeField]
private float InitialSpeed;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();
rb.AddForce(new Vector3(Random.Range(-1f, 1f), Random.Range(-1f, 1f), 0) * InitialSpeed, ForceMode.VelocityChange);
}
}