Engine
Engine copied to clipboard
Impossibility of a dynamic viewmodel change
Describe the bug
It's possible to change player's model via 'setmodel' command in real time, but for some reason that doesn't work for the viewmodel.
VScript implementation example:
function SwapViewmodel()
{
EntityGroup[2].SetModel("models/weapons/v_viewmodelname.mdl");
EntityGroup[3].SetModel("models/weapons/v_viewmodelname.mdl");
}
To Reproduce
Make it possible to change the viewmodel in real time.
Issue Map
Expected Behavior
Current viewmodel will change to a different one.
Operating System
No response
I feel like this is more overcomplicated than it should be. You can just get the ViewModel using Entities.FindByClassname. The only pitfall with this is that in SP it's viewmodel, in MP it's predicted_viewmodel.
local entity = Entities.FindByClassname(null, "viewmodel");
entity.SetModel("models/weapons/v_357.mdl");
or this in the console
script Entities.FindByClassname(null, "viewmodel").SetModel("models/weapons/v_357.mdl")
Maybe we could expose this in a better way, but if you're doing it through vscript this is the preferred method.