I have map based cars that I am converting a different entity type.
The issue is, these cars have window props that are parented to them, so when I swap out the models, the two models start colliding, and it's a mess. ent:GetChildren seems to return nothing at all. Is there anything I'm doing wrong here?
[code]
local IDCont = tonumber( val )
local ModelCont = ent:GetModel()
local MapContainerToNut = ents.Create("nut_storage");
MapContainerToNut:SetPos(ent:GetPos())
MapContainerToNut:SetAngles(ent:GetAngles())
-- A fix for car windows.
for k, v in pairs( ent:GetChildren() ) do
v:SetParent( MapContainerToNut )
end
MapContainerToNut:Spawn()
MapContainerToNut:SetModel(ModelCont)
MapContainerToNut:SetSolid(SOLID_VPHYSICS)
MapContainerToNut:PhysicsInit(SOLID_VPHYSICS)
MapContainerToNut.MapContainer = true;
MapContainerToNut:setNetVar("container", true)
MapContainerToNut.container = IDCont
local physObj = MapContainerToNut:GetPhysicsObject()
if (IsValid(physObj)) then
physObj:EnableMotion(false)
physObj:Sleep()
end
ent:Remove()
[/code]
Is it not grabbing the children because it's a map-based entity? :v
[editline]22nd February 2017[/editline]
Moved it to:
InitPostEntity()
seems to be working now.
Sorry, you need to Log In to post a reply to this thread.