- Home /
Move one vertice of my cube
Hi to all. I have a script to change the position of the first vertice of my cube:
function Update () {
// Get instantiated mesh
var mesh : Mesh = GetComponent(MeshFilter).mesh;
// Randomly change vertices
var vertices : Vector3[] = mesh.vertices;
Myvertices[0]=Vector3(0,2,0);
mesh.vertices = vertices;
mesh.RecalculateNormals();
}
The problem is that the code not works in the function Create. Only works in the Update. I need ejecute the code in Create function.
Any solution? Thanks in advance!!
Answer by Mike 3 · Mar 21, 2011 at 01:38 PM
My guess is that you need to put it in Awake or Start, Create isn't called automatically by the engine.
If you're calling Create from somewhere else, you'll probably need to add in more code, what you have above should work in Start/Awake
Your answer
Follow this Question
Related Questions
Cycle Through Array - Change Values 0 Answers
variable with int value not passing to command 1 Answer
Cycling Texture Array 1 Answer
Generating a cube mesh with two given points 1 Answer
Array Problem - Error Code BCE0022 1 Answer