Jump to content

Getting values from group:AddProperty( )


Matthew Nicholls
 Share

Recommended Posts

Hi all,

Can anyone help with this? It is driving me crazy. ;)

What I am trying to do is use a slider in the properties pannel for a model to control the blend value of the animation. The code below has only the basic stuff that is relevant to the problem.

 

The Slider shows fine in the properties pannel. But I can't get the blend value back to use in the Update function. At the moment the only way to change the blend value is to adjust the number in the Animations table. I tried object.model:SetKey("Idle","0.0") before Update() and many other options, but I just can't get it to work.

 

 

function class:InitDialog(grid)
     self.super:InitDialog(grid)
     group = grid:AddGroup("Animation")
     group:AddProperty( "Idle", PROPERTY_FLOAT,"0.0,1.0")
     group:Expand(1)
end

 

 

 

function class:CreateObject(model)
local object=self.super:CreateObject(model)


     object.Animations = {{blend = 0.0}   -- Idle blend value
                                      ,{blend = 0.0}}

     function object:Update()
           for count = 1 , #self.Animations do
                 if self.Animations[count ].blend > 0.0  then
                       self.model:Animate(#,self.Animations[count ].blend,#,#)
                 end
            end
     end


     function object:SetKey(key,value)
           if key =="" then
           elseif key == "Idle" then
                 self.Animations[1].blend = tonumber(value)
           else
                 return self.super:SetKey(key,value)
           end
           return 1
     end



     function object:GetKey(key,value)		
           if key == "Idle" then
                 return self.Animations[1].blend
           else
                 return self.super:GetKey(key,value)
           end
           return value
     end

end -- end of class

 

 

Any help on this would be greatly appriciated :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...