Background for Skyrim SE
Member of the Form script
eventOnAnimationEvent(ObjectReferenceakSource, stringasEventName)

Description

Wiki Description

Event called when the active magic effect/alias/form receives one of the animation events it was listening for.

Documentation Comment

Animation event, sent when an object we are listening to hits one of the events we are listening for


Caveats

CK Wiki - Notes

  • Aliases and quests will automatically unregister for this event when the quest stops. Active magic effects will automatically unregister when they are removed.
  • This event is not relayed to any aliases or magic effects attached to the form.
  • This event is relayed to other scripts attached to the same object. eg. On a quest form with 2 main quest scripts and a fragment script, an update event registered by one will be received by all three.
  • The game will allow you to register ANY animation event, valid or invalid. Though they may register successfully not all of them will necessarily generate events. See the discussion page for more information.
  • Animation Event Logger can be used to see what animation events are fired at any time.

Parameters

ObjectReferenceakSource

CK Wiki Description

The ObjectReference that sent the event.

stringasEventName

CK Wiki Description

The event that was received.


Examples

Function SomeFunction()
  RegisterForAnimationEvent(JoeBob, "IdleFurnitureExit") ; Before we can use OnAnimationEvent we must register.
EndFunction

Event OnAnimationEvent(ObjectReference akSource, string asEventName)
  if (akSource == self) && (asEventName == "Reset")
    Debug.Trace("We got the reset animation graph event from ourselves that we were looking for!")
  endIf
endEvent
Scriptname DetectCastEventScript extends Quest

Event OnInit()
    RegisterForAnimationEvent(Game.GetPlayer(), "BeginCastRight") 
    RegisterForAnimationEvent(Game.GetPlayer(), "BeginCastLeft") 
    RegisterForAnimationEvent(Game.GetPlayer(), "MRh_SpellFire_Event") 
endEvent


Event OnAnimationEvent(ObjectReference akSource, string asEventName)
     if (akSource == Game.GetPlayer()) && (asEventName == "BeginCastRight")
           Debug.MessageBox("BeginCastRight Registered!")
     endIf
    if (akSource == Game.GetPlayer()) && (asEventName ==  "MRh_SpellFire_Event")
           Debug.MessageBox("SpellFire_Event Registered!")
     endIf
endEvent

Auto-Generated Example

Scriptname MyCoolScript extends Form

event OnAnimationEvent(ObjectReference akSource, string asEventName)
    Debug.trace("Event received - OnAnimationEvent: akSource = " + akSource + " asEventName = " + asEventName)
endEvent

Related Pages


Additional References

View this event’s page on the Skyrim Creation Kit Wiki

Some data provided by the Skyrim Creation Kit Wiki. Licensed under the Creative Commons Attribution-ShareAlike license.