1. Post #1
    Gold Member
    sniperlover's Avatar
    February 2007
    1,261 Posts
    I'm trying to create a model to basically overlap another entity and use its animations and I'm getting some weird errors:
    SetBoneMatrix: Bone is unwriteable
    :7: attempt to index field 'matr2' (a nil value)
    :7: attempt to index field 'matr' (a nil value)
    Code:
    local ent = Entity(111)
    ent.CNPCModel = ClientsideModel("models/Zombie/Classic.mdl")
    function ent:BuildBonePositions()
    for i=1,self:GetBoneCount() do
    self.matr = self:GetBoneMatrix(i)
    self.matr2 = self.CNPCModel:GetBoneMatrix(i)
    self.matr2:Translate(self.matr:GetTranslation())
    self.matr2:Rotate(self.matr:GetAngle())
    self.CNPCModel:SetPos(self:GetPos())
    self.CNPCModel:SetBoneMatrix(i,self.matr2)
    end
    end

  2. Post #2
    Gold Member
    AzuiSleet's Avatar
    September 2007
    758 Posts
    The bone setup is threaded, there's a chance it might not always be able to lock the bone matrix for writing, so it will sometimes return nil. Or in some cases the bone may be read-only or it's invalid.