Creating Resource to add onAnimationTrigger back to 1.2
by Kevin Mitchell · in Torque 3D Professional · 05/30/2012 (4:25 am) · 12 replies
So after diffing the 1.1 and the 1.2 I see there's a new way to do the call backs and maybe this one never got completed? I don't know but I know its a really awesome feature I need right now. So hopefully this week i can get this working again. I see where it adds the triggers but it looks like there no check for the trigger anywhere any more.
I hope it was not removed because it was too much for the system to process. That would make me sad. But hopefully I can get this feature back soon.
I hope it was not removed because it was too much for the system to process. That would make me sad. But hopefully I can get this feature back soon.
About the author
Riding Solo since 2005. Current Project: Fated World 2005-Present RPG Engine Tool Kit - Now available.
#2
Thanks.
05/30/2012 (5:09 am)
this did not come up in my searches... Interesting... I'll check it out. Thanks.
#3
Hmm I'm going to see if i can play with this and adapt it to their new methods as well. Thanks.
05/30/2012 (5:17 am)
I see why I might need the other resource. I wonder if the trigger can send the name back with the onAnimationTrigger_Callback. I noticed all the call backs are scripted differently now. I wonder if it was part of the speed enhancements they have done. Hmm I'm going to see if i can play with this and adapt it to their new methods as well. Thanks.
#4
You can read about it here:
At comment 354
Edit: the 4th post is about callbacks
05/30/2012 (5:21 am)
AFAIK the changes are made for documentation purposes, it is easier to read what the code does now.You can read about it here:
At comment 354
Edit: the 4th post is about callbacks
#5
Your callback declaration would be something like this:
And the implementation:
So then the trigger loop would look like this:
Be aware that action animations don't work with this too well, and you might have to implement a version specific to them.
05/30/2012 (5:23 am)
Yeah, you definitely can pass the animation name at the same time. I (re)implemented this stuff a while ago, and keep forgetting that resource existed to post that little tidbit there.Your callback declaration would be something like this:
DECLARE_CALLBACK( void, onAnimationTrigger, ( ShapeBase* obj, S32 state, const char* animName ) );
And the implementation:
IMPLEMENT_CALLBACK( ShapeBaseData, onAnimationTrigger, void, ( ShapeBase* obj, S32 state, const char* animName ), ( obj, state, animName ), "");
So then the trigger loop would look like this:
if (mShapeInstance && !isGhost()) {
for (U32 i = 1; i < 32; i++) {
if (mShapeInstance->getTriggerState(i)) {
const char* animName = st.thread->getSequenceName();
mDataBlock->onAnimationTrigger_callback(this,i,animName);
}
}
}Be aware that action animations don't work with this too well, and you might have to implement a version specific to them.
#7
At the risk of self serving promotion: DSQTweaker edits DSQ files to include triggers....
05/31/2012 (5:03 am)
Is the issue of adding triggers to sequences broken with the UI, or is it that triggers simply don't work?At the risk of self serving promotion: DSQTweaker edits DSQ files to include triggers....
#8
That is good to know. If I get 3rd party resources that are in DSQ then I know there is a tool to add triggers. Thanks.
05/31/2012 (8:01 pm)
@Rex,That is good to know. If I get 3rd party resources that are in DSQ then I know there is a tool to add triggers. Thanks.
#9
06/01/2012 (6:33 am)
I have added this and I'm using the shape editor to add triggers and there's an echo in the call back but it does not fire.
#10
06/01/2012 (10:32 am)
I got this to work, i'll dig out my changes and post in a little while if you need them
#11
06/01/2012 (3:50 pm)
yes please
#12
Anyhow it looks like I just used Richard Marrevee's resource (this first link Lucas posted)
but changed a couple of things
I didn't add in the scriptThis function but used getIdString() instead
and added in an extra sequence name parameter.
heres the modified part of advanceThreads
I've been meaning to convert it to IMPLEMENT_CALLBACK type thingy (what ever the technical name is i've no idea :p)
but this seems to work fine.
edit:-
the script function for the above is this, for a DataBlock called Catapult...
function Catapult::onAnimationTrigger(%this, %obj, %trigger, %seqName)
06/02/2012 (1:23 pm)
Sorry forgot :/Anyhow it looks like I just used Richard Marrevee's resource (this first link Lucas posted)
but changed a couple of things
I didn't add in the scriptThis function but used getIdString() instead
and added in an extra sequence name parameter.
heres the modified part of advanceThreads
// << Jonajoint Added -> animation Trigger Resource (Richard Marrevee)
if (mShapeInstance && !isGhost()) {
for (U32 i = 1; i < 32; i++) {
if (mShapeInstance->getTriggerState(i)) {
char slot[3];
dSprintf(slot,sizeof(slot),"%d",i);
Con::executef(mDataBlock,"onAnimationTrigger",this->getIdString(),slot,st.thread->getSequenceName());
}
}
}I've been meaning to convert it to IMPLEMENT_CALLBACK type thingy (what ever the technical name is i've no idea :p)
but this seems to work fine.
edit:-
the script function for the above is this, for a DataBlock called Catapult...
function Catapult::onAnimationTrigger(%this, %obj, %trigger, %seqName)
Torque Owner Lukas Joergensen
WinterLeaf Entertainment
A related resource that might be interesting aswell:
http://www.garagegames.com/community/resources/view/21654