Jump to content

[LUA] About Animation Manager Script


tipforeveryone
 Share

Recommended Posts

I want to make an one-time Animation for my model when pressing a Key,

 

I refered MonsterAI.lua to learn how AnimationManager works then try applying to my script, but it does not work. Here were my steps, did I miss something smile.png ?

 

--Step1
import("Scripts/AnimationManager.lua")

--Step2
function Script:Start()
self.model = Model:Load("mymodel.mdl")
self.animMan = AnimationManager:Create(self.model)
end

--Step3
function Script:UpdateWorld()
if window:KeyHit(Key.A) then
self.animMan:SetAnimationSequence("attack",0.5,0.5)
end
end

 

 

Maybe I did not really understand the process smile.png show me please

Link to comment
Share on other sites

Sorry not going to be by a computer for a few days and i dont have Animationmanager.lua handy so ill show you the arguments for the c++ animation manager.

 

void SetAnimationSequence(const std::string& pSequence, const float pSpeed = 1.0f, const int pBlendTime = 500, const bool pMode = false, func_ptr pEndHook = nullptr);

 

(Ignore endhook because that arguments different here, but up to there its the same on the Lua version (except every numeric type in Lua is a double.).)

 

Try:

Self.animMan:SetAnimationSequence("attack", 0.4, 500, 1)

 

So that'd be speed of 0.4 blendtime of 500 and a mode (repeat or not?) of 1 (Don't repeat).

Right now your blend time of 0.5 seems really, really low... And im not sure if 'mode' defaults to one or zero.

 

Edit:

Just checked before leaving for the weekend... in the Lua AnimationManager 'mode' defaults to 0 which is repeat mode.... The line I pasted above should w/o a doubt work.

 

Although are you sure self.model is the entity you're meaning to attach this to? and not 'self.entity'? I'm just saying this because it looks like you're meaning to attach your script to an entity in the editor, which would then make the visible object you see in the editor 'self.entity'.

  • Upvote 1
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...