i copied code from a video but it doesnt work

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public static class NewBehaviourScript
{
  

public static readonly Vector3[] voxelverts = new Vector3[8]{}

  new Vector3(0,0f,0,0f,0,0f),
  new Vector3(1,0f,0,0f,0,0f),
  new Vector3(0,0f,1,0f,0,0f),
  new Vector3(0,0f,0,0f,1,0f),
  new Vector3(1,0f,0,0f,1,0f),
  new Vector3(1,0f,1,0f,1,0f),
  new Vector3(0,0f,1,0f,1,0f),

public static readonly int[,] voxeltris new int[6,6] {}

}

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Chunk : MonoBehaviour
{

public meshrenderer meshrenderer;
public meshfiltrer meshfiltrer;

void start () {

int vertexindex = 0;
list vertices = mew list();
list triangles = new list ();

for (int i = 0; i < 6; i++) {

int triangleindex = VoxelData.voxeltris [0, i];
vertices.add (VoxelData.voxelverts [triangleindex]);
triangle.add (vertexindex);

vertexindex++;
mesh mesh = new mesh();
mesh.vertices = vertices.toarray ();
mesh.triangle = triangle.toarray ();

mesh.recalculatenormals ();

meshfiltrer.mesh = mesh;

}
}
}

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Chunk : MonoBehaviour
{

public meshrenderer meshrenderer;
public meshfiltrer meshfiltrer;

void start () {   

     int vertexindex = 0;
     list<vector3> vertices = mew list<vector3>();
     list<int> triangles = new list<int> ();

     for (int i = 0; i < 6; i++) {

       int triangleindex = VoxelData.voxeltris [0, i];
       vertices.add (VoxelData.voxelverts [triangleindex]);
       triangle.add (vertexindex);

       vertexindex++;
       mesh mesh = new mesh();
       mesh.vertices = vertices.toarray ();
       mesh.triangle = triangle.toarray ();

       mesh.recalculatenormals ();

       meshfiltrer.mesh = mesh;
      
      

        }
    }
}

You copied it incorrectly, I would suggest you check again as your voxelverts array isn’t initialized correctly. You should have some errors there.

ok thanks ill try

also can you tell me what errors do i have
thx

Readonly int [,] probably shouldn’t have a comma in the brackets.

It’s valid syntax. That’s how multidimensional arrays are created in C#.

You can tell us, open your console by clicking on the bottom bar of the Unity editor. Your compiler errors should be there.

Just glancing through your code though, I can see a TON of things: Missing = sign in line 19, no semicolons anywhere in the first script, curly brackets are all in wrong places, and more. In your other two script you have not capitalized many things correctly (capitalization matters), misspelled “MeshFilter”. You also seem to have misnamed your first script’s class, you have it called “NewBehaviourScript” but the third script is attempting to access it via the name VoxelData.

Basically, go through your script and the script you copied from, and make it actually match.

1 Like

well first tell me where the brackets should be, second i mispell things a lot

and whats capitalization?

In programming, 100% of everything must be spelled correctly, capitalized correctly, and also punctuated correctly.

It’s almost as though the entire software engineering field was created by some sadistic grade school English teacher who hates everybody.

But you actually can get used to it: Look how much software is created every day!

I recommend you take a nice deep breath and start back here: Learning

If you prefer to randomly type in scripts from videos I assure you this is unlikely to result in anything meaningful or rewarding, but I would never tell you what to do.

3 Likes