x


Why does my script-made mesh only look visible from one side???

Here is the script...

var newVertices : Vector3[]; var newTriangles : int[];

function Update () { var mesh : Mesh = GetComponent(MeshFilter).mesh;

mesh.Clear();
// Do some calculations...
mesh.vertices = newVertices;
mesh.triangles = newTriangles;

}

I then make 4 vertices and 4 faces as a pyramid, but I can only see a single triangle.

Any help is very much appreciated.

Also, I already read the Unity Scripting Reference, and I didn't see this mentioned.

more ▼

asked Mar 23 '12 at 08:02 PM

MasterGalaxy gravatar image

MasterGalaxy
61 5 7 8

Thanks Dave, I hadn't thought of that. Your answer is much appreciated.

Mar 24 '12 at 03:36 AM MasterGalaxy
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

All triangles are single-sided (by default). The order which the vertices are linked determines which direction they face. Try reversing the order on the not-visible ones. That said, there are some shaders that have backface culling turned off, or you can learn shader language enough to modify existing shaders to do that, and all triangle would be drawn two-sided.

more ▼

answered Mar 23 '12 at 08:07 PM

DaveA gravatar image

DaveA
26.5k 151 171 256

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x237
x139
x137

asked: Mar 23 '12 at 08:02 PM

Seen: 349 times

Last Updated: Mar 24 '12 at 03:36 AM