thanks
i’m loking these examples.
and for fire state i’m trying to make trigger animation like in ninja example - with events.
i’m create file for R2_FIRE.ani name is R2_FIRE.xml
with this text
<animation>
<trigger time="0.6" type="String" value="RUKA.L.001" />
</animation>
remark : 0.6 = 15(in this frame must be event) / 25 (all frames in anim fire)
[code]void Start()
{
…
SubscribeToEvent(node_, E_ANIMATIONTRIGGER, HANDLER(ScriptR2Bot, HandleAnimationTrigger));
…
}
void ScriptR2Bot::HandleAnimationTrigger(StringHash eventType, VariantMap& eventData)
{
using namespace AnimationTrigger;
//EVENT(E_ANIMATIONTRIGGER, AnimationTrigger)
//{
// PARAM(P_NODE, Node); // Node pointer
// PARAM(P_NAME, Name); // String
// PARAM(P_TIME, Time); // Float
// PARAM(P_DATA, Data); // User-defined data type
//}
AnimationState* as = animModel_->GetAnimationState(StringHash(eventData[P_NAME].GetString()));
if (as)
{
String name = eventData[P_DATA].GetString();
Node* bone = node_->GetChild(StringHash(name), true);
}
}
[/code]
but in first time this not work, I’ve been thinking why? And then I thought of why.
At the node to which I Subscribe the event there is no component AnimationMesh
I corrected this place :
SubscribeToEvent(GetNode(), E_ANIMATIONTRIGGER, HANDLER(ScriptR2Bot, HandleAnimationTrigger));
to
SubscribeToEvent(node_, E_ANIMATIONTRIGGER, HANDLER(ScriptR2Bot, HandleAnimationTrigger));
and now everything seems working well