0 votes

2D nodes get a _draw virtual function, but there's nothing similar for Spatial nodes. What is the best way to create new geometry at runtime? Is creating new meshes every frame a good idea? Are there some less-obvious ways to draw geometry than MeshInstance? How does GridMap do its dynamic geometry? Could I make my own class inheriting from VisualInstance, and if so, how would that draw?

asked Jul 21 in Engine by Anna Harren (12 points)

By drawing geometry, do you mean create new polygons? With vertices and normals and all? That can be done in a few ways according to the docs. https://docs.godotengine.org/en/3.1/tutorials/content/procedural_geometry.html
ImmediateGeometry is a node that creates new geometry on the fly, but since it operates in real time, it is expensive and should be used for simple geometry only.
SurfaceTool is another way to create polygons once and then make the appear in game.
Finally, you have arrays which you turn into meshes.

1 Answer

0 votes
answered Jul 22 by MakLinux (26 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.