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?

in Engine by (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
by (29 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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.