RenderEntity
RenderEntity
is a clientside-only entity class that lets you draw simple meshes.
The API is pretty simple and lets you provide dynamic vertex data on a per-frame basis.
Creating a basic sprite
For most use cases it's sufficient to just derive from the RenderEntity
class and override the DoRender
method:
Then you can spawn them like this:
Keep in mind that creating RenderEntities serverside does not work-- they simply won't spawn.
Dynamic expressions
If your materials have dynamic expressions, you can write to their variables by calling Render.Attributes.Set
inside your DoRender
method. The values you set will affect all subsequent draw calls in the method body.
Limitations
Due to the large size of the RenderEntity
vertex format, vertex buffers created with Render.GetDynamicVB()
can only contain approximately 600 vertices. If you exceed this limit, you may experience crashes.
If you need more vertices, you can either use multiple vertex buffers or use the Mesh
class instead (which allows you to use a custom vertex format).