Animation-Event Message

From TrainzOnline
(Difference between revisions)
Jump to: navigation, search
m (1 revision)
m
Line 1: Line 1:
 
Generic events can be linked to an animation key frame to give a measure of control over script timing. This is a different mechanism from Sound_Event, which interfaces with a ''soundscript'' container in config.txt and does not require scripting.
 
Generic events can be linked to an animation key frame to give a measure of control over script timing. This is a different mechanism from Sound_Event, which interfaces with a ''soundscript'' container in config.txt and does not require scripting.
  
When an animation file, *.kin, is exported from Max or Gmax, the exporter will make a query for an event file. Tick the box and you will be asked to browse to the file. The event information is added to the contents of the new animation.
+
When an animation file, *.kin, is exported from Max, the exporter will make a query for an event file. Tick the box and you will be asked to browse to the file. The event information is added to the contents of the new animation.
  
 
* To produce an animation event which can be read by script you need to insert a line or lines similar to that below to a plain text file and to save it with an *.evt file extension.
 
* To produce an animation event which can be read by script you need to insert a line or lines similar to that below to a plain text file and to save it with an *.evt file extension.

Revision as of 19:34, 25 March 2010

Generic events can be linked to an animation key frame to give a measure of control over script timing. This is a different mechanism from Sound_Event, which interfaces with a soundscript container in config.txt and does not require scripting.

When an animation file, *.kin, is exported from Max, the exporter will make a query for an event file. Tick the box and you will be asked to browse to the file. The event information is added to the contents of the new animation.

  • To produce an animation event which can be read by script you need to insert a line or lines similar to that below to a plain text file and to save it with an *.evt file extension.
002 Generic_Event animstart
  • This example will result in the message Animation-Event,animstart being sent by the game whenever the animation plays past frame 2.
  • It is best to avoid issuing events on the first or last frames since these are not always converted reliably into messages.
  • To use the message you should define a handler using:
AddHandler(me,"Animation-Event","","AnimationHandler");
void AnimationHandler(Message msg) {
   if (msg.minor == "animstart") 
      Interface.Print("Animation has started");
   else if (msg.minor == "animstop") 
      Interface.Print("Animation has completed");
}
  • In practice the game engine often issues duplicate messages so you will need to ensure that you are not responding more often than necessary. One way of doing this is to use a boolean variable to keep track of what your script is doing and use this to ignore duplicating script actions.


See Also

Personal tools