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

Editing setmodel

From Quake Wiki

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
''void'' '''setmodel'''(''entity'' e, ''string'' modelPath)
+
====Syntax:====
 +
<code>void setmodel(entity e, string path)</code>
  
== Usage ==
+
Sets the model an entity will use.
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.
+
====Parameters:====
 
+
:<code>e</code> - The entity who's model is being set
For BSP models this also sets up the size information of the entity meaning <code>setsize()</code> should not be used on them. BSP entities will automatically store their model name in their '''model''' field on map load, so calling <code>setmodel(self, self.model);</code> will work for things like platforms, doors, and trains.
+
:<code>path</code> - The path to the model file to set.  Can be a model (.mdl), sprite (.spr) or map (.bsp)
 
+
====Returns:====
To clear a model, setting '''model''' to ""/'''string_null''' or setting '''modelindex''' to 0 will work.
+
:void
 
 
=== Parameters ===
 
*''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 ==
 
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");
 
}
 
  
 
[[Category:QuakeC Function]]
 
[[Category:QuakeC Function]]

Please note that all contributions to Quake Wiki are considered to be released under the GNU Free Documentation License 1.3 or later (see Quake Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel | Editing help (opens in new window)