Matthew Nicholls Posted November 24, 2011 Share Posted November 24, 2011 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 Quote Link to comment Share on other sites More sharing options...
Gabriel Posted November 30, 2011 Share Posted November 30, 2011 hello try with 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 as same for GetKey, the key return key in lowercase Gabriel Quote Link to comment Share on other sites More sharing options...
Matthew Nicholls Posted December 1, 2011 Author Share Posted December 1, 2011 Woo hoo it works thanks so much! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.