Garry's Mod

Garry's Mod

SGM's Vehicle Model Attaching Framework
 This topic has been pinned, so it's probably important
SGM ツ  [developer] Oct 23, 2022 @ 12:58pm
How to use
For vehicle developers
Add the following code at the bottom of the lua file for your vehicle:
SGM = SGM or {} SGM.AttachModels = SGM.AttachModels or {} SGM.AttachModelsByClass = SGM.AttachModelsByClass or {} SGM.AttachedModels = SGM.AttachedModels or {} SGM.AttachModels["models/my/car.mdl"] = { { Model = "models/my/car_model2.mdl", Pos = Vector(0,0,0), Ang = Angle(0,0,0), Color = Color(255,255,255), Scale = 1, -- BodyGroups = { -- {1,1}, -- {2,1}, -- }, BoneMerge = true, --bone merging, pretty self-explanatory BoneParent = "", --bone parenting, this makes the prop follow a specific bone RenderMode = RENDERMODE_NORMAL, --render mode just in case you need it, although you usually shouldn't Sync = true, --sync colors,materials, and bodygroups between the two models SyncSubMaterials = true, --sync submaterials between the models -- SyncFunction = function(car, prop) -- if !IsValid(car) or !IsValid(prop) then return end --if you really know what you're doing you can add custom functions for interactions between the vehicle and the prop, these get called each sync (default: every 2 seconds) -- end, -- SubMaterials = { -- [0] = "sentry/shared/skin0", --ability to change the submaterials of the prop if necessary -- }, }, }
All of these properties are optional, for optimization, make sure to disable syncing functions if you don't need them.

For Photon "developers"
Add the following code at the bottom of the lua file for your vehicle:
SGM = SGM or {} SGM.AttachModels = SGM.AttachModels or {} SGM.AttachModelsByClass = SGM.AttachModelsByClass or {} SGM.AttachedModels = SGM.AttachedModels or {} SGM.AttachModelsByClass["class_name_of_my_photon_car"] = { { Model = "models/tadano/fumo/pack/cirno.mdl", Pos = Vector(0,0,0), Ang = Angle(0,0,0), Color = Color(255,255,255), Scale = 1, -- BodyGroups = { -- {1,1}, -- {2,1}, -- }, BoneMerge = false, --bone merging, pretty self-explanatory BoneParent = "", --bone parenting, this makes the prop follow a specific bone RenderMode = RENDERMODE_NORMAL, --render mode just in case you need it, although you usually shouldn't Sync = false, --sync colors,materials, and bodygroups between the two models SyncSubMaterials = false, --sync submaterials between the models -- SyncFunction = function(car, prop) -- if !IsValid(car) or !IsValid(prop) then return end --if you really know what you're doing you can add custom functions for interactions between the vehicle and the prop, these get called each sync (default: every 2 seconds) -- end, -- SubMaterials = { -- [0] = "sentry/shared/skin0", --ability to change the submaterials of the prop if necessary -- }, }, }

Example of adding two models to the same car
You can add as many models as you want, as long as you add them properly.
SGM = SGM or {} SGM.AttachModels = SGM.AttachModels or {} SGM.AttachModelsByClass = SGM.AttachModelsByClass or {} SGM.AttachedModels = SGM.AttachedModels or {} SGM.AttachModels["models/my/car.mdl"] = { { Model = "models/my/car_model2.mdl", Pos = Vector(0,0,0), Ang = Angle(0,0,0), Color = Color(255,255,255), Scale = 1, -- BodyGroups = { -- {1,1}, -- {2,1}, -- }, BoneMerge = true, --bone merging, pretty self-explanatory BoneParent = "", --bone parenting, this makes the prop follow a specific bone RenderMode = RENDERMODE_NORMAL, --render mode just in case you need it, although you usually shouldn't Sync = true, --sync colors,materials, and bodygroups between the two models SyncSubMaterials = true, --sync submaterials between the models -- SyncFunction = function(car, prop) -- if !IsValid(car) or !IsValid(prop) then return end --if you really know what you're doing you can add custom functions for interactions between the vehicle and the prop, these get called each sync (default: every 2 seconds) -- end, -- SubMaterials = { -- [0] = "sentry/shared/skin0", --ability to change the submaterials of the prop if necessary -- }, }, { Model = "models/my/car_model3.mdl", Pos = Vector(0,0,0), Ang = Angle(0,0,0), Color = Color(255,255,255), Scale = 1, -- BodyGroups = { -- {1,1}, -- {2,1}, -- }, BoneMerge = true, --bone merging, pretty self-explanatory BoneParent = "", --bone parenting, this makes the prop follow a specific bone RenderMode = RENDERMODE_NORMAL, --render mode just in case you need it, although you usually shouldn't Sync = true, --sync colors,materials, and bodygroups between the two models SyncSubMaterials = true, --sync submaterials between the models -- SyncFunction = function(car, prop) -- if !IsValid(car) or !IsValid(prop) then return end --if you really know what you're doing you can add custom functions for interactions between the vehicle and the prop, these get called each sync (default: every 2 seconds) -- end, -- SubMaterials = { -- [0] = "sentry/shared/skin0", --ability to change the submaterials of the prop if necessary -- }, }, }
Last edited by SGM ツ; Oct 25, 2022 @ 12:24pm
< >
Showing 1-10 of 10 comments
W4nou Oct 25, 2022 @ 10:24am 
is there already a way to change the body groups of the added model? if not, is it planned for a future update?
SGM ツ  [developer] Oct 25, 2022 @ 11:17am 
Originally posted by W4nou:
is there already a way to change the body groups of the added model? if not, is it planned for a future update?
it's possible to add, but the original idea was that as a vehicle developer you'd only want to either sync bodygroups between two models if they match, or not change bodygroups at all because you would have already set up the model how you wanted it. it can be added though
W4nou Oct 25, 2022 @ 11:29am 
it's not for a vehicle it's only for a skin without emergency lights and i would have like to add models to it
Last edited by W4nou; Oct 25, 2022 @ 11:35am
SGM ツ  [developer] Oct 25, 2022 @ 12:25pm 
Originally posted by W4nou:
it's not for a vehicle it's only for a skin without emergency lights and i would have like to add models to it
added, make sure to disable syncing otherwise the vehicles bodygroups will take priority
W4nou Oct 25, 2022 @ 1:11pm 
amazing, thank you
sol Oct 28, 2022 @ 6:21am 
sgm can i pm u in any way i need help with my vcmod purchase, i tried reaching out to free and he didnt respond
76561199444131364 Jan 18, 2023 @ 10:48am 
2
I hate SGM. Just waste of internet for bloatware and more lag.
Sanya Jan 18, 2023 @ 10:57am 
Originally posted by porkicurtu:
I hate SGM. Just waste of internet for bloatware and more lag.
yeah ur mother told me how much she hated you last night when i got done with her, Told her we should of aborted
SMG4 Fan Jul 25, 2023 @ 4:16pm 
its no working
_Doctor_Gunner_ Oct 23, 2023 @ 12:06am 
Is simfphys supported?
< >
Showing 1-10 of 10 comments
Per page: 1530 50