Computer Games
--
Questions
--
Followers
Top Experts
Assembling 3d model programmatically in unity
How to assemble 3d models( individual 3d components) in unity or any game engine, programmatically, with out structural positions.
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
I had done similar, with a terrain engine in Unity. Â I had created a noise engine to produce different numbers for heights at various positions. Â Then I passed in an array of vertice positions based on that. Â Attach a MeshFilter, and meshRenderer. Â And then in code, you can reset the mesh vertices.
Something like
In my code I had a 2D array of 100x100 positions, each 1 meter apart on x/y, and then a noise engine set the height. Â that's pretty easy. Â
I.e.
please note, this is pseudo code I just sketched here, so it may not compile. Â But it might as well. Â (hopefully I didn't forget anything :)
Something like
// insert function to generate an array of Vector3 positions for your model
var verts = GenerateMeshVertices();
// apply the vertices
GetComponent<MeshFilter>().mesh.vertices = verts;
In my code I had a 2D array of 100x100 positions, each 1 meter apart on x/y, and then a noise engine set the height. Â that's pretty easy. Â
I.e.
// insert function to generate an array of Vector3 positions for your model
Vector3[] GenerateMeshVertices()
{
var verts = new Vector3[100,100];
for (int x; x < 100; x++)
{
for (int z; z < 100; z++)
{
var y = Random.Value;
verts[x, z] = new Vector3(x,y,z);
}
}
return verts;
}
please note, this is pseudo code I just sketched here, so it may not compile. Â But it might as well. Â (hopefully I didn't forget anything :)






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Computer Games
--
Questions
--
Followers
Top Experts
Computer games are video games played on a personal computer, mobile device or video game console. Their defining characteristics include a lack of any centralized controlling authority, a greater degree of user control over the video-gaming hardware and software used and a generally greater capacity in input, processing, and output.
Create your account and start contributing!