Jump to content

Key release function for idle animation?


psychoanima
 Share

Recommended Posts

I have 3 .fbx animation, one is for running, second is idle, third jumping. (2.5d platformer)

 

To trigger running I am using

 

if window:KeyDown(Key.D) then
self.entity:SetAnimationFrame()
end

 

Problem:

how to trigger idle animation since there is no Key release function? And how to blend it with previous animation?

 

 

Second problem:

I notice this when I am using KeyDown function: When I am pressing key to start the animation, releasing the key stops animation in the viewer, but animation is still looping somewhere in the background. I noticed that when I do quick press/release button on my keyboard - animation is cycling instead of starting from beginning.

Link to comment
Share on other sites

I found the answer for one part of my question.

 

I forgot to mention that for running animation I was using Time:GetCurrent() in SetAnimationFrame, that's why I get unwanted cycling animation.

 

My code is now like this:

 

 


local isrunning = 1

function Script:Draw()

if window:KeyDown(Key.C) then
isrunning = isrunning +1
self.entity:SetAnimationFrame(isrunning,1,1)

end

 

 

now I need to figure out how to add Idle when no key is pressed and how to blend it properly.

Link to comment
Share on other sites

I'd also recommend using the AnimationManager lua class that Josh has provided. It's just a nice utility class to deal with animation/blending/complete callback.

 

I am using Josh 2D platformer script example, but I have to reshape a lot of things cuz not everything is working how I wanted. I am not sure how to find AnimationManager lua class, I am rookie here, sry laugh.png

 

 

BTW SetInput function is a time saver for sidescroller moving!

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