Jump to content

Character controller LUA scripting


FoxMulder
 Share

Recommended Posts

Hello everyone,

I'm a newcomer to Lua and Leadwerks.

I have imported a premade animated model into Leadwerks in FBX format.

It works perfectly however I can't find any reference about activate animations through LUA scripting.

E.g. I would like to make a character walking forward on W KeyHit.

 

All tutorials I've found till now are about C++.. :(

 

Can anyone help me?

Link to comment
Share on other sites

I think you are a little confused between animation and character controller movement. Animation is the movement of bones where are controller movement is the character actually moving somewhere. They are independent of each other.

 

Controller movement is controlled with this command:

http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/entity/entitysetinput-r706

The FPSPlayer.lua file shows pretty well how to do the controller movement.

 

Animation is controlled with this command:

http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/entity/entitysetanimationframe-r141

Animation is generally pretty simple in that you just set a frame (i.e. use Time:Millisecs() or something to change the frame) and pick and animation.

Link to comment
Share on other sites

Hi,

 

I have a character with a set of animations, and my controller's animation section uses the Animation Controller Script. this lets you have a set of looped animations, anf pretty much 'just works' for walk cycles etc. You will need to change speed/blend to match you animations rate.

 

http://www.leadwerks.com/werkspace/page/documentation/_/script-reference/animationmanager-r693

 

it looks like:

 

function Script:UpdateWorld()

 

if self.parentEntity.script.isAttacking == true then

self.baseAnimMgr:SetAnimationSequence(self.AnimAttack, 0.05, 200)

else

if self.parentEntity.script.playerMovement.z ~=0 or self.parentEntity.script.playerMovement.x ~=0 then

if self.parentEntity.script.enteredWater == true then

self.baseAnimMgr:SetAnimationSequence(self.AnimSwim, 0.05, 200)

else

self.baseAnimMgr:SetAnimationSequence(self.AnimWalk, 0.05, 200)

end

 

else

self.baseAnimMgr:SetAnimationSequence(self.AnimIdle, 0.005, 200)

end

end

 

 

Hope that helps

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...