In my game, the player is presented with a plane containing obstacles (orange / blue) and regions of empty space (white).
The player moves their green cube around the empty space, which instantiates a trail of green cubes behind it, painting the path they’ve travelled.
I need to detect when the player has painted all of the empty space, so that they can proceed to the next level.
public float speed = 10f;
private RaycastHit hit;
public GameObject paintcube;
float maxdistance = 0.51f;
bool moves;
private void FixedUpdate()
{
Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * 3, Color.green);
if (Physics.Raycast(transform.position,transform.TransformDirection(Vector3.forward), out this.hit, maxdistance/*,layerMask*/))
{
if (hit.collider.gameObject.tag == "myobstacle")
{
moves = false;
}
if(moves)
{
movepaint();
}
}
}
public void movepaint()
{
if (moves)
{
MyList.Add(Instantiate<GameObject>(paintcube, position, transform.rotation));
}
}