Jump to content

End Hook On PlayAnimation Gets Called In Begining


reepblue
 Share

Recommended Posts

I've uploaded the needed files to replicate this bug. If you press "T", the model will do it's attacking animation but the test function will fire as soon as you press "T", and not after the animation is done. Watch "Done!" pop up in the log in the script editor as soon as the animation starts!

 

 

endhookbug.zip

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

Here is the correct method to use:

function Script:testend()
	System:Print("Done!")
end

function Script:Draw()
	if window:KeyHit(Key.T) then 
		self.entity:PlayAnimation("attack0",0.03,300,1,"testend")
	end
end

You were actually calling the function and passing the result (nil) as a function parameter.

The function EndAnimation() will always be called if it is present, so you can just do this:

function Script:EndAnimation(sequence)
	System:Print("Done!")
end

function Script:Draw()
	if window:KeyHit(Key.T) then 
		self.entity:PlayAnimation("attack0",0.03,300,1)
	end
end

This is the recommended method.
 

  • Confused 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

1 minute ago, reepblue said:

From the documentation, it makes it like you can call specific functions after each animation. Working now, gotta make some adjustments though.

You can! But this is really just there for backwards compatibility. I should probably remove that from the docs and just leave it in silently.

EndAnimation can receive an integer argument for the current sequence.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

  • 3 months later...
  • 3 weeks later...

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