Model Entities
Model entities are an entity that is visually representing by a .gltf
or .glb
model. Model entities are the most common type of entity you'll use. For example, players, enemies in your game, fixed and moving elements like lamp-posts or birds, and more, will typically be created using an Entity.
Common Uses & Examples
Let's dive into some common patterns when using model entities.
Bullet Entity
Some games may want a bullet that moves through the physical world and registers a hit when it intersects with another entity. You could alternatively just use a Raycasts for this, but in this example we'll use an entity.
Extra Large Entity
With model entities, you can control their physical scaling in the world. This allows you to scale up or down the model of the entity relative to its initial size. We'll use model scale to create a massive spider.
Now, we'll see a massive spider!
Automatic Model Optimizations
Typically, most model editing software will export your .gltf
and .glb
models with many internal meshes and named nodes. The more unique meshes & named nodes that make up your model, the more strain it puts on a device's GPU when your game is played. If you have a variety of loaded entity models at the same time, or your models have many complex meshes, this can cause a significant degradation of frame rate and overall game performance for players.
Because of this, the HYTOPIA SDK when you run your game server, and when your game is uploaded to the HYTOPIA platform, will automatically run a variety of optimization passes on each of your models and output them into a hidden .optimized
folder in your game's assets
folder.
Each model is ran internally through our gltf-transform based optimizer, performing operations like merging redundant meshes, named nodes, and other optimizations in various combinations, resulting in multiple .gltf
models for the same input model, outputted into the automated .optimized
directory.
The HYTOPIA client based on how you use your models will try to load the most optimal version of that model at runtime. This results in the best model for performance & your usage being used automatically, dramatically improving device frame rate and performance.
Overall, you don't need to manage or do anything with this system. It is automated and 100% internally managed.
If for some reason you are experiencing unusual behavior that you think is coming from optimized models, you can disable model optimization globally by invoking the following method of the ModelRegistry class at the beginning of your index.ts game script.
Last updated