Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

End Hook On PlayAnimation Gets Called In Begining


reepblue

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

Link to post

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
Link to post
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.

Link to post
  • 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.

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.

Facebook Twitter Youtube Github Steam
×
×
  • Create New...