Using animator inputs through script - Outerra/anteworld GitHub Wiki

Before reading this tutorial, please see Animator editor for more information.

This tutorial is focused on using animator inputs through vehicle_script and aircraft_script interfaces (in vehicles and aircrafts), in JavaScript/Lua script.

To use animator input, you need to have one created. This is done in the "Animator editor -> Inputs" tab.

https://github.com/Outerra/anteworld/wiki/Animator-editor#inputs

image

You can create inputs of type bool, float or int.

Note: these inputs are used as conditions in Animator Editor nodes, determining when the nodes are activated or deactivated

https://github.com/Outerra/anteworld/wiki/Animator-editor#nodes

In script

Get animator input index

To get/set inputs through script, you first have to get the input index, using following function:

// JavaScript
input_index = this.get_animator_input_index("input_name")

-- Lua
input_index = self:get_animator_input_index("input_name")

When you have the input index, you can use it as parameter in following functions (which are based on the input type), to get/set animator input:

Get animator input value

  • Get bool input
// JavaScript
this.get_animator_input_bool(input_index)

-- Lua
self:get_animator_input_bool(input_index)
  • Get float input
// JavaScript
this.get_animator_input_float(input_index)

-- Lua
self:get_animator_input_float(input_index)
  • Get int input
// JavaScript
this.get_animator_input_int(input_index)

-- Lua
self:get_animator_input_int(input_index)

Set animator input value

  • Set bool input
// JavaScript
this.set_animator_input_bool(input_index)

-- Lua
self:set_animator_input_bool(input_index)
  • Set float input
// JavaScript
this.set_animator_input_float(input_index)

-- Lua
self:set_animator_input_float(input_index)
  • Set int input
// JavaScript
this.set_animator_input_int(input_index)

-- Lua
self:set_animator_input_int(input_index)