> For the complete documentation index, see [llms.txt](https://docs.flatredball.com/flatredball/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flatredball.com/flatredball/gum/animations/setting-gum-animationchain-achx-in-code.md).

# Setting Gum Animationchain Achx in Code

### Introduction

Gum objects support playing .achx animations. This enables the use of the familiar AnimationEditor to create texture-based animations for Gum objects. Note that AnimationChain animations are used to change texture or texture coordinates. These are typically used for animated characters in 2D games. AnimationChain animations cannot change the size, orientation, or other common Gum properties.

### Note About Glue Version

Glue Version 12 introduces automatic calling of AnimateSelf on the top-level Gum screen. If your Glue project is using an earlier version than version 12, you will need to explicitly add the following to your CustomActivity:

```
GumScreen.AnimateSelf();
```

For more information on Glue versions, see the [gluj/glux page](/flatredball/glue-reference/glujglux.md).

### Setting Animations

For this example we will assume a Sprite named SpriteInstance.

![](/files/bEZzktC9njMBlaIKunCK)

This Sprite is contained in a page named MainMenuGum which is assumed to be inside a FlatRedBall Screen named MainMenu.

![](/files/m3HnHnWxdB3ayBmDYqhJ)

We can set the Sprite to be animated using the following code in CustomInitialize:

```
var gumSprite = GumScreen.SpriteInstance;

gumSprite.Animate = true;
gumSprite.CurrentChainName = "CharacterWalkRight";
// The SourceFile property is a Texture2D, but we can also set it to
// a file path which will resolve to an animation using the SetProperty method.
gumSprite.SetProperty("SourceFile", "../Screens/MainMenu/PlatformerAnimations.achx");
gumSprite.TextureAddress = Gum.Managers.TextureAddress.Custom;
```

The Gum Sprite now animates when running the game.

<figure><img src="/files/Q0m5VSJpi0XMbEr8m3sL" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.flatredball.com/flatredball/gum/animations/setting-gum-animationchain-achx-in-code.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
