Entity.SetModel
From GMod Wiki
Function | |
Syntax | Entity:SetModel( String modelname ) |
Description: | |
Sets the model of the entity. This is used both in scripted entities and before creating hard-coded entities (like prop_physics). | |
Returns: | nil |
In Object: | Entity |
Realm: | |
BBCode Link: | [b][url=http://wiki.garrysmod.com/?title=Entity.SetModel]Entity.SetModel [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Examples
Description | Sets the model of a scripted entity in the initilization function. |
---|---|
Used on | |
Code | function ENT:Initialize() self:SetModel("models/props_c17/oildrum001.mdl") end |
Output | N/A |
Additional Notes
- Several folders will be searched to find the model.
- First off it will search the garrysmod folder.
- After that it will check the currently active gamemode's content folder.
- If the first two options fail it will also search the GCFs of your installed steam games if the model isn't found in the Garry's Mod folder.
- Models can be browsed in the Hammer editor included with the source SDK. You can copy the model path directly from it.
- It's not necessary to call util.PrecacheModel() before setting a model, but the server will temporarily lag every time an uncached model is spawned, so it is good practice to call util.PrecacheModel once before setting the model.