aego/anim
An animation clip reaches an event, and the scripts on the player's node get OnAnimEvent(id int, payload float). Events are declared by name in Project Settings → Animation; anim.EventName and anim.EventID turn ids into names and back. An unknown id has the name "", an unknown name the id -1. See Animation.
Example
package demo
import (
"aego/anim"
"aego/log"
)
script Listener {
var hit int
func Ready() {
hit = anim.EventID("Hit")
log.Info("Hit has the id " + string(hit) + ", id 0 is called '" + anim.EventName(0) + "'")
}
func OnAnimEvent(id int, payload float) {
if id == hit {
log.Info("hit for " + string(payload))
}
}
}
Functions
| EventID | (name string) int | Returns the id of an event declared in Project Settings → Animation, or -1. |
| EventName | (id int) string | Returns the name of an animation event, or an empty string for an unknown id. |
| ParamIndex | (controller AssetRef<animctrl>, name string) int | Returns the index of a parameter of a controller, or -1. |
| StateName | (controller AssetRef<animctrl>, index int) string | Returns the name of a state of a controller, or an empty string. |
EventID function
func EventID(name string) int
Returns the id of an event declared in Project Settings → Animation, or -1.
Example
hit := anim.EventID("Hit")
EventName function
func EventName(id int) string
Returns the name of an animation event, or an empty string for an unknown id.
Example
func OnAnimEvent(id int, payload float) {
if anim.EventName(id) == "Hit" {
ParamIndex function
func ParamIndex(controller AssetRef<animctrl>, name string) int
Returns the index of a parameter of a controller, or -1.
See the module example for this function in use.
StateName function
func StateName(controller AssetRef<animctrl>, index int) string
Returns the name of a state of a controller, or an empty string.
See the module example for this function in use.