- Home /
Creating Meshes and Physics Objects At Runtime
Could someone explain how to make a game object with a custom mesh at runtime? For example, if I have 8 points in world space, could that be translated into an object that I could then apply physics to? Could this new mesh be concave? Could it be re-manipulated once the mesh is created?
Any info regarding this subject would be appreciated. Thanks! :)
Answer by Eric5h5 · Apr 17, 2010 at 08:03 PM
Have a look at the Mesh class. The mesh you make can be used in the mesh collider.
Interesting, thanks for that link. Do you happen to have a link or some example code on how to create something relatively simple like a cube at runtime? The script reference is good, but example code would probably help me understand this a little better.
@SpikeX: These examples use the $$anonymous$$esh class a lot: http://unity3d.com/support/resources/example-projects/procedural-examples
Answer by Cyclops · Apr 17, 2010 at 09:01 PM
I also have a demo on the Unify Wiki on Creating a Fake Gizmo, which creates a Procedural Mesh, which may help clarify the procedure.
FYI, I created the sample Arrows by taking a Blender model and exporting it to .FBX, then wrote a Python script that extracted the vertex/triangle information, for cutting/pasting into Unity code.
Your answer
Follow this Question
Related Questions
Mesh creation during runtime 0 Answers
How to create a custom cuboids at runtime? 1 Answer
Mesh Resolution Problem 1 Answer
Modifying a Mesh at Runtime 1 Answer