arrow-left

All pages
gitbookPowered by GitBook
1 of 56

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

AnythingAnimate

AnythingWorld.AnythingAnimate

hashtag
Static Methods

Allows the user to send a model to be rigged and animated through Animate Anything directly through Unity.

Allows the user to poll for a model's current state in the Animate Anything processing pipeline.

hashtag
Description

A class that provides methods for interfacing with Animate Anything directly in Unity.

hashtag
Example

Poll

AnythingWorld.AnythingAnimate.Poll

hashtag
Declaration

hashtag
Parameters

AddCollider

AnythingWorld.RequestParameter.AddCollider

Declarations

Parameters

hashtag

Animate

AnythingWorld.AnythingAnimate.Animate

hashtag
Declaration

hashtag
Parameters

AnythingMaker

AnythingWorld.AnythingMaker

hashtag
Static Methods

AnythingWorld API

Namespace

hashtag
Description

Top level namespace of the AnythingWorld package, holds main user facing functionality.

hashtag

hashtag
Description

A class that provides methods for creating game objects from the Anything World database based on search terms and parameters.

Make

This method allows users to request an object from the Anything World database and have it instantiated in the scene according to the parameters they pass in.

Animate
Poll
Description

Add collider around object that encloses object mesh(es).

public static AddCollider AddCollider()
public static AddCollider AddCollider(bool value)

value

Add collider to object

public class MyTestScript : MonoBehaviour 
{
    string myModelPath = "C:\Users\User\Desktop\MyModel.fbx"
    string myExtraAssetsPath = "C:\Users\User\Desktop\MyModelAssets"

    string myModelName = "My Model";
    string myModelType = "Human";
    string authorName = "Model Author";
    string myModelLicense = "MIT";
    bool myModelSymmetry = true;
    bool myModelUsedForImprovement = false;

    private void Start() 
    {
        AnimateMyModel();
    }

    public void AnimateMyModel()
    {
        AnythingAnimate.Animate(
            myModelPath, 
            myExtraAssetsPath,
            myModelName,
            myModelType,
            authorName,
            myModelLicense,
            myModelSymmetry,
            myModelUsedForImprovement,
            PollMyModel,
            PrintDebugWhenAnimateFail)
    }
    
    // This function will be invoked if the model has successfully been sent to Animate Anything
    public void PollMyModel(string ID)
    {
        AnythingAnimate.Poll(
            PrintDebugWhenPollSuccessful,
            PrintDebugWhenPollFail,
            PrintDebugWhenPoll,
            ID);
    }
    
    // This function will be invoked if the model has successfully been animated by Animate Anything
    public void PrintDebugWhenPollSuccessful(ModelJson details)
    {
        Debug.Log("Model successfully animated!");
        AnythingMaker.Make(details);
    }
    
    // This function will be invoked if an error was encountered in animating the model
    public void PrintDebugWhenPollFail(string code, string message)
    {
        Debug.LogError("Could not animate model!");
    }
    
    // This function will be invoked whenever the model is polled for
    public void PrintDebugWhenPoll(string code, string message, int seconds)
    {
        Debug.Log("Polling for update on my model!");
    }
    
    // This function will be invoked if an error was encountered in sending the file to Animate Anything
    public void PrintDebugWhenAnimateFail(string ID, UnityWebRequest error)
    {
        Debug.LogError("Could not send model to be animated!");
    }
}

Function asking the user what to do once the model has finished processing. ModelJson parameter contains the necessary details to create the model using .

onProcessFail

Function asking the user what to do if an error occurs whilst processing. First string parameter contains the error code. Second string parameter contains the error message.

onProcessPoll

Function asking the user what to do whilst processing. First string parameter contains the current output code. Second string parameter contains the message. The int parameter accounts for how many seconds the model has been processing for.

id

The ID of the model to poll.

(timeout)

The amount of time in seconds before the polling times out. Standard timeout is set to 10 minutes.

hashtag
Description

Allows you to poll for a model's current state in the Animate Anything processing pipeline. This polls continuously until the model either produces a failure or a successful result.

hashtag
Example

onProcessFinished

Reference to the model that should be rigged through Animate Anything.

modelName

The name of the model when accessed through My World.

modelType

The type of the model, as used when determining what skeleton to rig the model as (see the for more details on what types are currently supported).

authorName

The name of the original author of the model.

license

The license attributed to the model.

symmetrical

Flag for determining if the model is symmetrical or not.

allowSystemImprovement

Flag asking if the user allows Anything World to use the model for internal improvements.

onExport

Function asking the user what to do once the model has been sent to be processed. String parameter outputs the ID of the model.

onError

Function to be executed if an error occurs in sending the model to be processed. String parameter outputs the ID of the model if one has been supplied, UnityWebRequest parameter contains the request details such as error codes and messages.

(additionalAssetsPath)

Path to a folder containing any additional assets separate from the original model. If no additional assets are necessary, this can be left empty.

hashtag
Description

Allows you to send a model to be rigged and animated through Animate Anything directly through Unity. If the model is sent to be animated without error, an ID will be generated that can be used to poll the current progress of the model's animation process. This function is Editor only.

This function works from a direct reference to a game object. Please note that the model needs to be of a valid file type (.obj, .fbx, .dae, .gltf, or .glb). Any additional assets uploaded similarly need to be of a valid asset file type (a list of these valid file types, as well as additional constraints can be found here). The additional assets path must lead to a folder which contains the assets. Ensure that any paths used are relative paths to the Assets folder.

hashtag
Example


hashtag
Declaration

hashtag
Parameters

modelPath

Path to the model that should be rigged through Animate Anything.

additionalAssetsPath

Path to a folder containing any additional assets separate from the original model. If no additional assets are necessary, this can be left empty.

modelName

The name of the model when accessed through My World.

modelType

The type of the model, as used when determining what skeleton to rig the model as (see the for more details on what types are currently supported).

authorName

The name of the original author of the model.

license

The license attributed to the model.

symmetrical

hashtag
Description

Allows you to send a model to be rigged and animated through Animate Anything directly through Unity. If the model is sent to be animated without error, an ID will be generated that can be used to poll the current progress of the model's animation process.

This function uses a path to reference the model. This path needs to be a direct path to the model, including its extension type. Please note that the model needs to be of a valid file type (.obj, .fbx, .dae, .gltf, or .glb). Any additional assets uploaded similarly need to be of a valid asset file type (a list of these valid file types, as well as additional constraints can be found here). The additional assets path, unlike the model path, must lead to a folder which contains the additional assets. Ensure that the paths used are absolute paths.

hashtag
Example

model

Classes

A class that provides methods for creating game objects from the Anything World database based on search terms and parameters.

A class that provides methods for interfacing with Animate Anything directly in Unity.

Utility for building and passing parameters to the maker pipeline.

Namespaces

Namespace holding scripts handling speech-to-text, text-to-speech and command parsing functions.

RequestParameter

AnythingWorld.RequestParameter

hashtag
Static Methods

Add collider around object that encloses object mesh(es).

Add Rigidbody to object.

hashtag
Description

Utility for building and passing parameters to the maker pipeline.

public static void Poll(Action<ModelJson> onProcessFinished, Action<string, string> onProcessFail, Action<string, string, int> onProcessPoll, string id)
public static void Poll(Action<ModelJson> onProcessFinished, Action<string, string> onProcessFail, Action<string, string, int> onProcessPoll, string id, int timeout)
public class MyTestScript : MonoBehaviour 
{
    string myModelID = "416e797468696e67476f6573";

    public void PollMyModel()
    {
        AnythingAnimate.Poll(
            PrintDebugWhenSuccessful,
            PrintDebugWhenFail,
            PrintDebugWhenPoll,
            myModelID);
    }
    
    // This function will be invoked if the model has successfully been animated by Animate Anything
    public void PrintDebugWhenSuccessful(ModelJson details)
    {
        Debug.Log("Model successfully animated!");
    }
    
    // This function will be invoked if an error was encountered in animating the model
    public void PrintDebugWhenFail(string code, string message)
    {
        Debug.Log("Could not animate model!");
    }
    
        // This function will be invoked whenever the model is polled for
    public void PrintDebugWhenPoll(string code, string message, int seconds)
    {
        Debug.Log("Polling for update on my model!");
    }
}
public static void Animate(GameObject model, string modelName, string modelType, string authorName, string license, bool symmetrical, bool allowSystemImprovement, Action<string> onExport, Action<string, UnityWebRequest> onError)
public static void Animate(GameObject model, string modelName, string modelType, string authorName, string license, bool symmetrical, bool allowSystemImprovement, Action<string> onExport, Action<string, UnityWebRequest> onError, string additionalAssetsPath = "")
public class MyTestScript : MonoBehaviour 
{
    public GameObject myModel;
    
    string myModelName = "My Model";
    string myModelType = "Human";
    string authorName = "Model Author";
    string myModelLicense = "MIT";
    bool myModelSymmetry = true;
    bool myModelUsedForImprovement = false;

    public void AnimateMyModel()
    {
        AnythingAnimate.Animate(
            myModel,
            myModelName,
            myModelType,
            authorName,
            myModelLicense,
            myModelSymmetry,
            myModelUsedForImprovement,
            PrintDebugWhenSuccessful,
            PrintDebugWhenFail)
    }
    // This function will be invoked if the model has successfully been sent to Animate Anything
    public void PrintDebugWhenSuccessful(string ID)
    {
        Debug.Log("Successfully sent my model to be animated!");
    }
    // This function will be invoked if an error was encountered in sending the file to Animate Anything
    public void PrintDebugWhenFail(string ID, UnityWebRequest error)
    {
        Debug.Log("Could not send my model to be animated!");
    }
}
public static void Animate(string modelPath, string additionalAssetsPath, string modelName, string modelType, string authorName, string license, bool symmetrical, bool allowSystemImprovement, Action<string> onExport, Action<string, UnityWebRequest> onError)
public class MyTestScript : MonoBehaviour 
{
    string myModelPath = "C:\Users\User\Desktop\MyModel.fbx"
    string myExtraAssetsPath = "C:\Users\User\Desktop\MyModelAssets"

    string myModelName = "My Model";
    string myModelType = "Human";
    string authorName = "Model Author";
    string myModelLicense = "MIT";
    bool myModelSymmetry = true;
    bool myModelUsedForImprovement = false;

    public void AnimateMyModel()
    {
        AnythingAnimate.Animate(
            myModelPath, 
            myExtraAssetsPath,
            myModelName,
            myModelType,
            authorName,
            myModelLicense,
            myModelSymmetry,
            myModelUsedForImprovement,
            PrintDebugWhenSuccessful,
            PrintDebugWhenFail)
    }
    // This function will be invoked if the model has successfully been sent to Animate Anything
    public void PrintDebugWhenSuccessful(string ID)
    {
        Debug.Log("Successfully sent my model to be animated!");
    }
    // This function will be invoked if an error was encountered in sending the file to Animate Anything
    public void PrintDebugWhenFail(string ID, UnityWebRequest error)
    {
        Debug.Log("Could not send my model to be animated!");
    }
}
AnythingMaker.Make

Flag for determining if the model is symmetrical or not.

allowSystemImprovement

Flag asking if the user allows Anything World to use the model for internal improvements.

onExport

Function asking the user what to do once the model has been sent to be processed. String parameter outputs the ID of the model.

onError

Function to be executed if an error occurs in sending the model to be processed. String parameter outputs the ID of the model if one has been supplied, UnityWebRequest parameter contains the request details such as error codes and messages.

FAQ arrow-up-right
FAQ
AnythingMaker
AnythingAnimate
RequestParameter
AnythingWorld.Voice
AnythingWorld.Utilities

Specify scripts to add to object after creation process has completed.

Clamp database scale between given values.

Make the object use the legacy animation system.

Place object on grid.

Set origin of object to the centre bottom of mesh bounds.

Set parent GameObject for created model.

Serialize model assets to database on loading completion.

Add default behaviour from default or given preset.

Define whether transformations (position, rotation) should be applied using world space or local space.

AddCollider
AddRigidbody
AddScripts
ClampDatabaseScale
LegacyAnimatorInEditor
PlaceOnGrid
PlaceOnGround
Parent
SerializeAsset
SetDefaultBehaviourPreset
TransformSpace

PlaceOnGrid

AnythingWorld.RequestParameter.PlaceOnGrid

Declarations

 public static RequestParameterOption PlaceOnGrid(bool value)

Parameters

value

Place object on grid.

hashtag
Description

Place object on grid.

LegacyAnimatorInEditorOption

AnythingWorld.RequestParameter.LegacyAnimatorInEditorOption

Declarations

public static LegacyAnimatorInEditorOption LegacyAnimatorInEditorOption(bool value)

Parameters

value

Tells AnythingWorld to use the legacy animation system for the created model.

hashtag
Description

Make the object use the legacy animation system.

AddRigidbody

AnythingWorld.RequestParameter.AddRigidbody

Declarations

public static AddRigidbody AddRigidbody()
public static AddRigidbody AddRigidbody(bool value)

Parameters

value

Add Rigidbody to object.

hashtag
Description

Add Rigidbody to object.

AddScripts

AnythingWorld.RequestParameter.AddScripts

Declarations

public static RequestParameterOption AddScripts(params Type[] scriptTypes)
public static RequestParameterOption AddScripts(params MonoBehaviour[] monobehaviours)

Parameters

scriptTypes

Types of scripts to be added to object. (must be derived from MonoBehaviour)

monobehaviours

MonoBehaviour scripts to be added to object.

hashtag
Description

Specify scripts to add to object after creation process completed.

IsAnimated

AnythingWorld.RequestParameter.IsAnimated

Declarations

public static RequestParameterOption IsAnimated(bool value)

Parameters

value

Set if model animation should be requested.

hashtag
Description

Request model with animation system if available.

ScaleType

AnythingWorld.Utilities.UtilityEnum.ScaleType

SetRealWorld

The object's size is set to match its real-world size (as provided by database)

ScaleRealWorld

The object's size is scaled in relation to the real world.

Absolute

The object's size is an absolute value, not relative to the real world.

hashtag
Description

Enum defining the different types of scaling modes when creating AnythingWorld objects.

PlaceOnGround

AnythingWorld.RequestParameter.PlaceOnGround

Declarations

public static RequestParameterOption PlaceOnGround(bool value)

Parameters

value

Place object on ground

hashtag
Description

Set origin of object to the centre bottom of mesh bounds.

TransformSpace

AnythingWorld.RequestParameter.TransformSpace

Declarations

public static RequestParameterOption TransformSpace(Utilities.TransformSpace space)

Parameters

space

Enum defining the transform space to be used while applying transform properties to this model.

hashtag
Description

Define whether transformations (position, rotation) should be applied using world space or local space.

Parent

AnythingWorld.RequestParameter.Parent

Declarations

public static RequestParameterOption Parent(Transform parentTransform)

Parameters

parentTransform

Transform that model will be parented to.

hashtag
Description

Set parent GameObject for created model.

Rotation

AnythingWorld.RequestParameter.Rotation

Declarations

public static RequestParameterOption Rotation(Quaternion quaternionRotation)
public static RequestParameterOption Rotation(Vector3 eulerRotation)

Parameters

quaternionRotation

Quaternion rotation to be applied to transform.

eulerRotation

Euler rotation to be applied to transform.

x, y, z

Euler rotations in the X, Y and Z axis that will be applied to transform.

hashtag
Description

Set rotation of object transform.

SetDefaultBehaviourPreset

AnythingWorld.RequestParameters.SetDefaultBehaviourPreset

Declarations

public static RequestParameterOption SetDefaultBehaviourPreset()
public static RequestParameterOption SetDefaultBehaviourPreset(DefaultBehaviourPreset behaviourPreset)

Parameters

behaviourPreset

Scriptable object defining default behaviours for model categories.

hashtag
Description

Choose whether to apply behaviours from a default or given preset.

Scale

AnythingWorld.RequestParameter.Scale

Declarations

public static RequestParameterOption Scale(Vector3 scaleVector)
public static RequestParameterOption Scale(int x, int y, int z)

Parameters

scaleVector

Vector scale applied to transform.

x, y, z

Scale in the X, Y and Z axis that will be applied to transform.

hashtag
Description

Set scale of object transform.

Position

AnythingWorld.RequestParameter.Position

Declarations

public static RequestParameterOption Position(Vector3 positionVector)
public static RequestParameterOption Position(int x, int y, int z)

Parameters

positionVector

Position vector apply to object transform.

x, y, z

x, y and z position to apply to object transform.

hashtag
Description

Multiply the default or defined scale value by this value.

ScaleMultiplier

AnythingWorld.RequestParameter.ScaleMultiplier

Declarations

public static RequestParameterOption ScaleMultiplier(float scaleVector)

Parameters

scaleVector

Vector scale

x, y, z

Scale in the X, Y and Z axis that will be applied to transform.

hashtag
Description

Multiply the default or defined scale value by this value.

SerializeAsset

AnythingWorld.RequestParameter.SerializeAsset

Declarations

public static RequestParameterOption SerializeAsset()
public static RequestParameterOption SerializeAsset(bool value)

Parameters

value

Serialize this asset.

hashtag
Description

Serialize model assets to database on loading completion.

Idle

AnythingWorld.Animation.RunWalkIdleController.Idle

hashtag
Declaration

public void Idle()

hashtag
Description

Transition the object to the idle animation.

JumpStart

AnythingWorld.Animation.RunWalkIdleController.JumpStart

hashtag
Declaration

public void JumpStart()

hashtag
Description

Transition the object to the start of the jump animation.

Walk

AnythingWorld.Animation.RunWalkIdleController.Walk

hashtag
Declaration

public void Walk()

hashtag
Description

Transition the object to the walk animation.

public static RequestParameterOption Rotation(int x, int y, int z)

CommandRequester

Anythingworld.Voice.CommandRequester

hashtag
Methods

Requests a command from a plain text input string and handles resulting command through CommandHandler utility.

Requests a command from a plain text input string and returns the resulting command as a JSON-formatted string.

hashtag
Description

A class that handles sending plain text commands to our parsing API and then returning the parsed commands to users and handling the command.

OnFailAction

AnythingWorld.RequestParameter.OnFailAction

Declaration

public static RequestParameterOption OnFailAction(Action action)

hashtag
Parameters

action

Action that will be invoked on failed request.

hashtag
Declaration

hashtag
Parameters

hashtag
Description

Pass an action into make process that will be invoked on a failed model creation or request.

ScaleType

AnythingWorld.RequestParameter.ScaleType

Declarations

public static RequestParameterOption ScaleType(Utilities.ScaleType scaleType)

Parameters

scaleType

Type of scaling applied to this this model (See )

hashtag
Description

Multiply the default or defined scale value by this value.

RequestAndReturnCommand

AnythingWorld.Voice.CommandRequester.RequestAndReturnCommand

hashtag
Declaration

private static IEnumerator RequestAndReturnCommand(string input, Action<string> ReturnAction)

hashtag
Parameters

hashtag
Description

Requests a command from a plain text input string and returns the resulting command as a JSON-formatted string.

RequestCommand

AnythingWorld.Voice.CommandRequester.MakeCommand

hashtag
Declaration

 public static void RequestCommand(string input, Action<string> ReturnedCommandAction = null)

hashtag
Parameters

hashtag
Description

Requests a command from a plain text input string and handles resulting command through CommandHandler utility.

Voice

AnythingWorld.Voice

hashtag
Description

Namespace holding scripts handling speech-to-text, text-to-speech and command parsing functions.

hashtag
Classes

Utilities

AnythingWorld.Utilities

hashtag
Description

Namespace holding utility functions that are used throughout the different modules of the AnythingWorld package.

hashtag
Classes

ClampDatabaseScale

AnythingWorld.RequestParameter.ClampDatabaseScale

hashtag
Declarations

public static RequestParameterOption ClampDatabaseScale(Vector3 upperBound)
public static RequestParameterOption ClampDatabaseScale(Vector3 lowerBound, Vector3 upperBound)

hashtag
Parameters

hashtag
Description

Clamp database scale between given values.

LegacyAnimationController

AnythingWorld.Animation.LegacyAnimationController

Public Methods

Crossfade between the current animation and another animation

Play a new animation

Stop all animations

Controller waits a set length of seconds and then does a function call

UtilityEnum

AnythingWorld.Utilities.UtilityEnum

hashtag
Properties

Represents the type of scaling to be applied to a game asset.

ModelLoadingPipeline

Represents the type of model loading pipeline used for a game asset.

DefaultBehaviourType

hashtag
Description

Declares utility enums that are used throughout the project for creation processes.

Make

AnythingWorld.AnythingMaker.Make

hashtag
Declaration

public static GameObject Make(string name)

hashtag
Parameters

hashtag
Description

This method allows users to request an object from the Anything World database and have it instantiated in the scene according to the parameters they pass in. If no parameters are passed in the default parameters will be used.

Users can provide RequestParams, that can be created using the RequestParameter class.

hashtag
Example

OnSuccessAction

AnythingWorld.RequestParameter.OnSuccessAction

Declaration

public static RequestParameterOption OnSuccessAction(Action action)

hashtag
Parameters

action

Action with void return type that will be invoked on successful request.

hashtag
Declaration

Parameters

hashtag
Description

Pass action into make process that will be invoked on a successful model creation.

MovementJumpLegacyController

AnythingWorld.Animation.MovementJumpLegacyController

Public Methods

Blend between the different movement speeds of the object (Idle, Walk, and Run)

Transition the object to the idle animation.

Transition the object to the start of the jump animation.

Transition the object to the falling animation.

BlendAnimationOnSpeed

AnythingWorld.Animation.RunWalkIdleController.BlendAnimationOnSpeed

hashtag
Declaration

public void BlendAnimationOnSpeed(float speed)

hashtag
Parameters

hashtag
Description

Blend between the different movement speeds of the object (Idle, Walk, and Run)

public static GameObject Make(string name, params RequestParam[] parameters

input

Plain text command to be parsed by API.

OnSuccess

Action that will be invoked on successfully parsed and returned command, must take a string input

input

Plain text command to be parsed by API.

ReturnedCommandAction

Action that will be invoked on successfully parsed and returned command, must take a string input.

lowerBound

The lower bound of object scale.

upperBound

The upper bound of object scale.

speed

The speed of the object

RequestCommand
RequestAndReturnCommand
Utilities.ScaleType
CrossFadeAnimation
PlayAnimation
StopAnimations
Wait

Represents the default behaviour type for a game asset.

TransformSpace

Represents the space in which the transform parameters are applied.

RequestType

Represents the type of request to be made to the API.

SortingDropdownOption

Represents the sorting options for a dropdown menu.

ScaleType
public static RequestParameterOption OnFailAction(Action<CallbackInfo> action)

action

Action that will be invoked on failed request and passed a CallbackInfo as an action.

name

Name of model to request from database with or without GUID qualified. (eg. fox, cat#0001)

parameters

Optional list of request parameters (see: RequestParameter) to apply to this request, override default parameters.

public static RequestParameterOption OnSuccessAction(Action<CallbackInfo> action)

action

Action with CallbackInfo return type that will be invoked on successful object request.

//Creates a cat with some parameters.
public class MakeACreature : MonoBehaviour 
{
    public void MakeACat()
    {
    
        AnythingMaker.Make("cat",
            //Will add animation system if available
            RequestParameter.IsAnimated(true),
            //Sets position to zero
            RequestParameter.Position(Vector3.zero),
            //Adds default behaviours from preset
            RequestParameter.SetDefaultBehaviour(),
            //Set callbacks for successful creation.
            RequestParameter.OnSuccessAction(PrintDebugWhenSuccessful),
            //Set callback for failed creation.
            RequestParameter.OnFailAction(PrintDebugWhenFail),
             //Add another example script
            RequestParameter.AddScripts(typeof(UserScriptExample)));
    }
    // This function will be invoked if model creationg process successful
    public void PrintDebugWhenSuccessful()
    {
        Debug.Log("Finished making model!");
    }
    // This function will be invoked if the model creation process fails
    public void PrintDebugWhenFail()
    {
        Debug.Log("Could not finish making model!");
    }
    
}

This class handles sending plain text commands to our parsing API and then returning the parsed commands to users and handling the command.

Declares utility enums that are used throughout the project for creation processes.

Transition the object to the end of the jump animation.

Transition the object to the run animation.

Transition the object to the walk animation.

BlendAnimationOnSpeed
Idle
JumpStart
JumpFall
CommandRequester
UtilityEnum
Land
Run
Walk

Land

AnythingWorld.Animation.RunWalkIdleController.Land

hashtag
Declaration

public void Land()

hashtag
Description

Transition the object to the end of the jump animation.

Documentation

Behaviour Tree Editor

What is a Behaviour Tree?

A Behavior Tree (BT) is a hierarchical structure that defines the decision-making process of an AI agent. It consists of nodes that represent tasks or behaviors, which are executed based on certain conditions. The tree is traversed from the root node down to the leaf nodes, with each node returning Success, Failure, or Running status. Behavior Trees help you structure the decision-making logic of your agent, making complex behaviors manageable and understandable via visual representation.

hashtag
Main Concepts

hashtag
1. Action Nodes

Action nodes are the leaf nodes of the Behavior Tree. They represent the actual tasks or behaviors that the AI agent can perform. When an action node is executed, it attempts to carry out a specific action, such as moving to a target, attacking an enemy, or playing an animation.

hashtag
2. Composite Nodes

Organizational nodes that control the execution flow of their child nodes. There are several types of composite nodes, including:

  • Sequence: Executes its child nodes in order until one fails. If all child nodes succeed, the sequence node succeeds.

  • Selector: Attempts to execute its children one by one until one succeeds. It's used for selecting between different behaviors based on their success.

  • Parallel: Executes all its child nodes simultaneously and succeeds if a specified number of child nodes succeed.

For example you can have a "FindAndAttackEnemy" sequence node with two child nodes: "SearchForEnemy" and "AttackEnemy". The sequence node would first execute the "SearchForEnemy" node to locate an enemy. If an enemy is found, it would then execute the "AttackEnemy" node. If both child nodes succeed, the sequence node succeeds.

hashtag
3. Decorator Nodes

Modifiers that alter the behavior or outcome of their child nodes. They can be used to repeat actions, invert success/failure, or conditionally execute based on certain criteria. Common types of decorator nodes include:

  • Inverter: Inverts the success/failure status of its child node.

  • Repeater: Repeats the execution of its child node a specified number of times or until a condition is met.

  • Conditional: Executes its child node only if a specified condition is true.

A repeater node can execute the "AttackEnemy" node multiple times, allowing the AI agent to perform consecutive attacks.

hashtag
4. Blackboard

The Blackboard is a global data store that allows nodes to share information and state across the Behavior Tree. It acts as a key-value store, where nodes can read and write data. The Blackboard is useful for storing variables such as target positions, health values, or any other relevant information that nodes might need to access.

Run

AnythingWorld.Animation.RunWalkIdleController.Run

hashtag
Declaration

public void Run()

hashtag
Description

Transition the object to the run animation.

PlayAnimation

AnythingWorld.Animation.LegacyAnimationController.PlayAnimation

Declaration

public void PlayAnimation(string animationName)

Parameters

animationName

Name of animation to play

hashtag
Description

Play a new animation.

StopAnimations

AnythingWorld.Animation.LegacyAnimationController.StopAnimations

Declaration

public void StopAnimations()

hashtag
Description

Stop all animations.

JumpFall

AnythingWorld.Animation.RunWalkIdleController.JumpFall

hashtag
Declaration

public void JumpFall(bool fall)

Parameters

fall

Is the object falling?

hashtag
Description

Transition the object to the falling animation.

Idle

AnythingWorld.Animation.FlyingAnimationController.Idle

hashtag
Declaration

public void Idle()

hashtag
Description

Transition the object to the idle animation.

Fly

AnythingWorld.Animation.FlyingAnimationController.Fly

hashtag
Declaration

public void Fly()

hashtag
Description

Transition the object to the flying animation.

CrossFadeAnimation

AnythingWorld.Animation.LegacyAnimationController.CrossFadeAnimation

Declaration

public void CrossFadeAnimation(string animationName)

Parameters

animationName

Name of animation to crossfade to

hashtag
Description

Crossfade between the current animation and another animation.

FlyingAnimationController

AnythingWorld.Animation.FlyingAnimationController

Public Methods

Transition the object to the flying animation.

Transition the object to the idle animation.

Wait

AnythingWorld.Animation.LegacyAnimationController.Wait

Declaration

public IEnumerator Wait(float seconds, Action callback)

hashtag
Parameters

seconds

Length of time to wait for callback

callback

hashtag
Description

Controller waits a set length of seconds and then does a function call.

Path Creator

PathCreator is a tool for creating Bezier curve splines in the Scene view. These splines can be used to represent a path agents use to move. You can place objects and meshes along it for example to create roads. Read more about Bezier curve and how it is defined parametrically herearrow-up-right or watch this arrow-up-rightin-depth video.

hashtag
Getting started

To start creating a spline add a PathCreator component to any game object. Default spline with two anchors and two control points will be added to the scene.

circle-info

Adding a game object with PathCreator to a parent with significantly changed scale will result in spline having a huge initial size which is inconvenient to work with. In this case it is recommended to first create a game object with PathCreator at the top of the hierarchy and then add it as a child.

hashtag
Anchors and control points

Each segment of the spline is defined by two anchor points that determine the start and the end of the spline and two control points tied to anchors that determine the shape of the spline . When more segments are added intermediate anchors have two control points each determining the shape of neighbouring spline segments. To keep the spline curve smooth those control points are usually tied to each other and placed on a straight line but it's possible to change that using different Control Modes.

hashtag
Control Modes

To have more control over the spline shape you can choose how a control point opposite the one you are manipulating behaves:

  • Mirrored mode will place the opposite control at the same distance from anchor and directly opposite direction as the manipulated one.

  • Aligned mode changes the direction of the opposite control but keeps the original distance to anchor intact.

  • Free mode completely decouples two controls and allows changing them independently.

hashtag
Snap to Surface

Enables snapping of anchor and control points to the nearest surface. It can be useful if you want to create a ground path on an uneven surface. Snap mode uses anchor position to calculate the snapped positions of related controls so make sure to snap the anchor first by moving it until it snaps to the surface you want.

For best snapping accuracy it's recommended to manually set up Surface Orientation in corresponding dropdown.

circle-info

Surfaces with complex shapes or frequently changing angles can still lead to inaccuracies. Placing anchor points on each surface with different angles should help. If all fails you can always disable snapping mode, set up the problematic segment manually and then enable snapping mode again.

hashtag
Path Space

Choose between creating splines in 3D or 2D space, with 2D splines restricted to the XZ plane. Snapping is only available in 3D space.

hashtag
Normals

Opening Normals Options section will make normals visible. They determine the orientation of objects placed on a spline or moving along it. While you can set the global angle of normals it's also possible to fine tune them for each segment by clicking on anchor and enabling Unity's rotation tool by clicking on corresponding icon or pressing "E".

hashtag
Display Options

Constant Point Size makes it so that control and anchor points keep the same size when moving closer or farther from spline.

Global settings that also exist in Path Options (snap to surface, etc.) determine defaults when path is created or reset.

Deselect When Clicking Outside Spline determines if selection is changed if you click on empty space or other game object. If it's disabled you need to click anywhere in the Hierarchy window to deselect PathCreator object.

hashtag
Editing spline segments

  • Append: Shift + Left Mouse Button (LMB).

  • Prepend: Ctrl + Shift + LMB or Command + Shift + LMB on Mac.

  • Divide: Shift + LBM over a segment.

hashtag
Vertex Path

While Bezier Path tab shows a visualization of the spline, Vertex Path shows an actual curve that is created by sampling the curve equation at certain intervals. This allows to get a set of vertices which can be used while moving or placing objects along spline.

Vertex Path Options determine how close the resulting curve will resemble the original one. Changing the margins of error will reduce the Vertex count making it more lightweight while losing some degree of fidelity.

hashtag
Moving agents along spline

We've created a simple SplineMovement behaviour tree with MoveAlongSpline node. The code behind this node shows how spline points can be sampled programmatically to determine position and orientation of the agent on the spline. Example behaviour tree can be found at Assets/AnythingWorld/Examples/BTMovement. To see it in action open and run RandomMovement scene from the same folder. You can also see a more specific use case by downloading Extra scenes package from the bottom of your and running City_Day scene.

You can also add this BT to any game object to make it move along spline. Adding behaviour trees is explained in the previous section of documentation. After adding the BehaviourTreeRunner component and choosing SplineMovement as the BT you want to run, you also need to add a MovementDataContainer script which contains a field for PathCreator. Add your game object containing PathCreator component to this field and you are good to go.

hashtag
Creating a path programmatically

It is also possible to create a spline programmatically at runtime by using one of the constructors in BezierPath class. All you need to do is supply it with a set of 2d or 3d points and optionally specify if you want the spline path to be forming a loop and space of the path to be 3d or 2d.

Building Your Project

Some pointers about building for Unity while using Anything World.

hashtag
1. Included Shaders

When building projects that only use the runtime scripting API Unity will cull shaders that are not in use, so it's recommended to go to Project Settings > Graphics and add the default shaders used in the AW pipeline.

  • Standard (Metallic)

  • Standard (Specular)

  • Standard Transparent (Metallic)

  • Standard Transparent (Specular)

circle-exclamation

If there are not enough elements available then please increase the Size parameter to include the listed shaders. It is not recommended to change the existing shaders unless you have experience with this.

hashtag
2. MacOS Microphone Permissions

Some platforms including mobile and MacOS require a Microphone Usage description for builds that include microphone usage, this will usually be shown to users in a popup format when requesting microphone access.

To do this, navigate to Project Settings > Player > Other Settings > Mac Configuration > Microphone Usage Description.

Animation

AnythingWorld.Animation

hashtag
Description

Namespace holding scripts handling animation import and controllers.

Classes

MovementJumpLegacyController

How to use Behaviour Tree Editor

hashtag
Opening the editor

The Behavior Tree Editor can be accessed by either double-clicking an existing tree asset or through the tab located in AnythingWorld -> Behavior Tree Editor.

Behaviour Tree Editor can be opened via double clicking on existing tree asset or opening the tab in AnythingWorld -> Behaviour Tree Editor.

Behaviour Tree Editor view

hashtag
User interface overiew

hashtag
Node View

Displays behavior tree nodes and the edges connecting them. This area allows users to interact with the nodes, connect them to each other and visualize the tree structure.

hashtag
Node Inspector

Shows data associated with the currently selected node. Some fields are presented as dropdowns linked to blackboard keys, they have a special type of NodeProperty which allows them to interact with blackboard keys. Other fields are standard Unity serialized fields.

hashtag
Working with nodes

hashtag
Adding a node

To add a node, right-click on anywhere in the node view and select the desired node from the context menu. You can also start typing the name of the node to filter the list.

hashtag
Editing node code

Double-clicking on a node opens the code associated with it, allowing direct modifications to its behavior.

hashtag
Auto-scaling

Pressing "A" will auto-scale the node view to occupy the available window space fully, enhancing visibility.

hashtag
Behaviour Trees management

hashtag
Accessing behaviour trees

Clicking on the Asset menu in the upper left corner reveals a list of all behavior trees in the current project and provides an option to create new ones.

hashtag
Global settings

  • New nodes and trees are saved to default locations specified in the global BT settings, found at Assets/AnythingWorld/AnythingBehaviour/BehaviourTreeProjectSettings.asset.

  • Enable Node Values Copying setting determines whether node's field values will be deep copied when copy pasting nodes in node view.

circle-info

Deep copy works for most of the Unity and basic types. However, more complex ones like Lists of custom types may fail. In this case a warning will be shown and the value skipped.

hashtag
Integration and runtime behaviour

hashtag
Adding to GameObjects

  • To use a behavior tree with a GameObject, add the BehaviourTreeRunner component and select the appropriate tree. Once you add a tree it is automatically instantiated so you can edit it without changing the original asset.

  • BehaviourTreeRunner also allows adding blackboard overrides for any blackboard keys BT has. This is useful if you want to change parameters like speed without opening and editing a BT.

  • Overrides are applied when entering playmode so they need to be setup beforehand.

circle-info

Note that override will not work if any of the nodes write a value to that key effectively overwriting the value that you set in BehaviourTreeRunner.

  • Animated models in AnythingWorld Model Browser are imported with preset movement BTs depending on the model type. These default BTs can be changed via Make Options. You can also enable NavMesh usage which will make ground animals move using existing NavMesh or a generated one in case there is none in the scene.

hashtag
Execution flow visualization

When a scene is played, a runtime copy of the tree is created. If you've opened a Behaviour Tree Editor window before running the scene,d clicking on a GameObject with an active tree will visualize the execution flow, with colors indicating the state of each node. Yellow denotes nodes that returned Running state, green - nodes that returned Success state and red - nodes that returned Failure.

hashtag
Compatibility

Behavior trees should be created in the lowest Unity version they will be used with, as there is no downward compatibility between versions. You can see the lowest Unity version AnythingWorld currently supports .

hashtag
Extending Behaviour Tree with code

hashtag
Adding new node types

New node types can be added either through the context menu in the node view or by creating a new C# class that inherits from Action, Decorator, or Composite types. These classes must implement OnStart(), OnStop(), and OnUpdate() functions, with OnUpdate() returning one of the node states.

hashtag
Shared context

Each node class has access to a shared context field which is an instance of Context class that stores commonly used components and subsystems. It is created from the game object that you attached BehaviourTreeRunner component to. You can extend it by adding components that you want all nodes to have access to like Colliders, RigidBodies, etc.

hashtag
Converting field to NodeProperty to enable blackboard interaction

To enable any field of a node to read or write to a blackboard key you must declare it as a NodeProperty<T> where T is the type of the property you want to declare, e.g. NodeProperty<float> speed. You can set a default value via constructor like so: NodeProperty<float> speed = new NodeProperty<float>(4). If you have a blackboard key of the same type it's possible now to associate speed NodeProperty with that key by choosing it from a dropdown in Node Inspector.

circle-info

Converting a field into a NodeProperty and connecting it to a blackboard key will also allow you to override its value in the BehaviourTreeRunner component as discussed earlier.

hashtag
Adding new blackboard key types

Opening Type dropdown when creating a new key will show most of the common C# and Unity types. However if you find some types lacking you need to add them manually by opening BlackboardKeyTypes.cs file and adding your type following the existing pattern.

circle-info

Since the blackboard view extends the default Unity inspector it should be able to show all the types Unity inspector supports. However, adding more complex custom types can lead to rendering as well as reading \ writing problems. They can be fixed in some cases but will require in-depth editing of Behaviour Tree Editor code.

hashtag
Moving agents with behaviour trees

You can find example random movement BTs for all types of AnythingWorld agents underAssets/AnythingWorld/Examples/BTMovement. To see them in action open and run RandomMovement scene from the same folder. There is also MoveAlongSpline BT which is explained in Path Creator documentation section.

All the random movement BTs follow the same logic:

  1. Generate a random position via random position node.

  2. Write it into a blackboard key.

  3. Use that position as movement destination in a MoveToDestination node.

However these nodes and their settings vary depending on the model type. The only variables common to all movement nodes and goal generation nodes are the following:

  • Min / Max Goal Spawn Radius - min / max random goal distance from agent's position.

  • Speed - initial speed of the agent.

  • Scale Speed With Model Speed - should we multiply the Speed by speedScalar? speedScalar is calculated from speed data specific to imported model.

hashtag
Ground agents movement

Both ground animals and vehicles have settings for movement and turning speed. However ground animals are also able to jump hence GroundAnimalMoveToGoal node in GroundAnimalRandomMovement tree has additional jump settings explained below:

  • Jump Detector Size - the distance at which an agent will try to detect an obstacle and either avoid it or jump on it. Consequently determines the distance between jump starting point and obstacle.

  • Scale Jump With Model Height - will decrease or increase both Max Jump Height and Jump Detector Size proportional to model's height.

  • MaxSlope - maximum slope of the surface an animal able to traverse. Any surface with slope above max is processed as an obstacle that will be avoided or jumped on.

You will notice that the movement node of GroundAnimalNavMesh tree has almost no jump settings. That's because NavMesh is used to calculate optimal routes and there cannot be arbitrary changes to movement trajectory. Jump areas must be explicitly defined via NavMeshLinks explained .

hashtag
Flying and swimming agents movement

While movement speed and rotation settings resemble previously discussed agents, goal generation has an added height constraint. Flying agent's AerialRandomGoal node has:

  • Ground Y Coordinate which defines the ground level with global Y coordinate.

  • Min / Max Flying Height - min / max height relative to ground. So if you have ground level set at 5 and min height set at 2, the agent's min flying height will be 7.

Swimming agents are similar but always stay below water surface. Hence FishRandomGoal node has only Surface Y Coordinate and Swimming Depth which is also relative to the surface.

The function to callback

Default legacy controller for rigged objects, such as animals and humans

FlyingAnimationController

Default legacy controller for flying objects, such as birds

Fly
Idle

Automatic mode will place all control points automatically maintaining the smooth shape of the spline.

Delete Anchor: Ctrl + LMB or Command + LMB on Mac.
profile pagearrow-up-right
Default spline
Editing segment normal
Vertex Path tab
Wait before generating a new position.

Stopping Distance - the remaining distance to the goal when the agent stops moving and considers the goal reached.

herearrow-up-right
herearrow-up-right
Behaviour Tree presets
Context class
Connecting NodeProperty to blackboard key.
Blackboard key type declarations.
Add the newly created URP Asset to the Scriptable Render Pipeline Settings in the Project Settings panel.
Include the following shaders
Example of a microphone usage description, you should tailor yours to the use case in your project.