Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!

setmodel

From Quake Wiki

void setmodel(entity e, string modelPath)

Usage[edit]

Sets the entity's model. Valid models must be precached at map load in order to be usable. This sets both the model and modelindex fields. The model index is the index within the cache which is not exposed to QuakeC, but can be set directly by storing the value and changing it. The model name and model index do not need to match as modelindex takes priority.

For BSP models this also sets up the size information of the entity meaning setsize() should not be used on them. BSP entities will automatically store their model name in their model field on map load, so calling setmodel(self, self.model); will work for things like platforms, doors, and trains.

To clear a model, setting model to ""/string_null or setting modelindex to 0 will work.

Parameters[edit]

  • e
The entity whose model is being set.
  • modelPath
The path to the model file to set. Can be a model (.mdl), sprite (.spr) or BSP (.bsp).

Example[edit]

void monster_my_monster()
{
    // Make sure the model is precached first in the initialization function
    precache_model("progs/mymonster.mdl");

    // Set the entity's model to mymonster.mdl
    setmodel(self, "progs/mymonster.mdl");
}