<!-- Page: https://rustic-game-engine.pages.dev/docs/api/animation/transition -->

# Animation.transition()

[Animation](https://rustic-game-engine.pages.dev/markdown/api/animation.md)

## Compatibility

**Supported languages:** C, C++, C#, Python, JavaScript, Lua 5.4, Luau, Java, PHP and HTML/inline JavaScript (binding spellings and return shapes differ).

Use a compatible native engine build and the language tools required by your binding. This does not establish browser/mobile export or release qualification for every OS.

The signature below is the shared reference notation; language examples show the actual binding syntax. Question marks mark optional arguments and explicit defaults are shown where recorded. Do not copy reference notation as a typed declaration.

See [Feature status and compatibility](https://rustic-game-engine.pages.dev/markdown/reference/compatibility.md) for API 1.0/1.1 and per-method restrictions. Engine release tags and Docs v0.1 are independent versions.

## Signature

`Animation.transition(entity, fromClip, toClip, options?)`

## Setup and usage

These engine-owned services work in Lua 5.4, Luau, JavaScript, Python, C, C++, C#, Java, PHP, and HTML inline JavaScript. Follow [Use gameplay actions](https://rustic-game-engine.pages.dev/markdown/guides/gameplay-actions.md) to create and attach a script, install external toolchains, and choose the correct language binding. PHP and HTML scripts belong under `ui/`; CSS alone runs no gameplay code.

The Calls section uses JavaScript signatures. The function examples below include native syntax for all ten script types, including SDK-specific alternatives and limitations. Attach a JavaScript Object Component script to the specified target and press **Play**. Globals are supplied by the engine. Schedule actions from `Start` or a callback, rather than at script top level. Native languages use typed options and their own builder conventions; see the guide's language bindings.

## Parameters

| Parameter | Meaning |
| --- | --- |
| clip | Object with name, positive duration, tracks and optional markers. A track contains target and keys. |
| keys | At least two time/value entries beginning at zero with strictly increasing times; a starting key's easing controls the following interval. |
| play options | speed (default 1), loop, blendIn/Out (seconds), blendInEase/OutEase, weight (default 1), additive, mask, layered, progressionEase. |
| blend options | duration (default 0.3 seconds) and easing for the transition, plus playback options. |
| marker | Source-clock time and event name; add before starting playback. |
| IK options | pole, weight, duration and easing; joints must form a direct root/middle/tip parent chain. |

## Return and timing

Clips lists registered names; load/register/addMarker update the engine registry. Play returns a handle with stop, speed, loop and onMarker in addition to standard controls. Value and procedural actions return operation handles; value callbacks receive the interpolated scalar/vector/quaternion.

## Execution behavior

Core write timing differs between immediate Lua host calls, deferred JavaScript/Web commands and external SDK query flushes. Scheduled actions advance with the scene clock; synchronous queries evaluate at the call. Follow [execution rules](https://rustic-game-engine.pages.dev/markdown/guides/scripting.md#when-mutations-take-effect) and the return/timing notes for this category.

## Language examples

Choose one snippet at a time and place it inside your language's Start/on_start callback. These are independent examples; each creates its own handles or builders. Follow [Gameplay language bindings](https://rustic-game-engine.pages.dev/markdown/guides/gameplay-actions/language-bindings.md) for imports and callback registration. Python must import the modules used in its snippet from rustic; C# uses using static Rustic; Java examples belong inside a Rustic subclass; PHP callbacks declare global $rustic. HTML snippets go inside an inline script in a ui/ HTML asset.

Use an anchored Part for transform and effect examples, an unanchored collidable Part for forces, and a perspective camera named Camera for camera examples. Create Target for follow examples. Audio examples require assets/music.ogg in the Play snapshot. Replace scene paths with those listed by Game.scene.List(). Animation playback and sequence-animation examples require the Reveal fixture on the [Animation page](https://rustic-game-engine.pages.dev/markdown/api/animation.md); marker callbacks also require its Halfway marker. Run clock controls separately; a paused clock cannot advance a timer.

C callback examples use these file-scope functions before on_start:

```c
static void on_done(void) { rustic.log("info", "done"); }
static void on_sample(RusticValue value) { (void)value; rustic.log("info", "sample received"); }
static void on_event(const RusticValue *args, size_t count) {
    (void)args; (void)count; rustic.log("info", "event received");
}
```

This minimal example blends two instances of Reveal. Replace the names with two registered clips for a pose change.

### Lua 5.4

```lua
Animation.transition(rustic.entity_id(), "Reveal", "Reveal")
```

### JavaScript

```javascript
Animation.transition(rustic.entity_id(), "Reveal", "Reveal");
```

### Python

```python
Animation.transition(rustic.entity_id(), "Reveal", "Reveal")
```

### C++

```cpp
Animation::transition(rustic.entity_id(), "Reveal", "Reveal", 0.3, Ease::OutCubic);
```

### C#

```csharp
Animation.transition(rustic.entity_id(), "Reveal", "Reveal", 0.3, Ease.OutCubic);
```

### Luau

```lua
Animation.transition(rustic.entity_id(), "Reveal", "Reveal")
```

### C

```c
Animation.transition(rustic.entity_id(), "Reveal", "Reveal", 0.3, Ease.OutCubic, NULL);
```

### Java

```java
Animation.transition(rustic.entity_id(), "Reveal", "Reveal", 0.3, Ease.OutCubic);
```

### PHP

```php
Animation::transition($rustic->entity_id(), "Reveal", "Reveal");
```

### HTML / inline JS

```javascript
Animation.transition(rustic.entity_id(), "Reveal", "Reveal");
```

## Shared Animation constraints

- Import glTF/GLB/FBX through Explorer and attach to the mesh entity to play skeletal clips. Source node_N descendants, inverse binds, skin weights and named clips are bound before Start. Use clips to discover actual names. Explicit load requires a fresh target.
- Tracks target Position, Rotation, Scale, Color, Opacity, Fov or child/path/Property. C/C++ use registerClip; native facades use typed clip/key/marker records.
- Source time is linear at selected speed unless progressionEase warps sampling. Markers use raw source time; running actions retain their clip snapshot. Blend duration stays in scene seconds when speed changes.
- Blend/transition samples both source and destination clips. Start a base clip before a masked layer; masks match track names or hierarchy prefixes. Additive tracks apply a delta from their initial pose.
- Turning loop off finishes the current cycle. Stop cancels without resetting the pose; completion retains the final pose unless blend-out restores the base.
- IK solves in world space, preserves segment lengths and clamps unreachable targets. FootPlacement aliases IK; headTracking is finite lookAt, requiring controller updates for changing targets.
- Clip limits are 4096 tracks, one million keys and 4096 markers. Add markers before playback because running actions retain their clip snapshots.
- glTF retains linear/step/cubic-spline interpolation; FBX is baked at 60 Hz. Live renderer skinning uses four linear influences. Morph targets, dual-quaternion skinning and animation graph/editor UI are not implemented.
- Check script attachment, enabled state and the Console when an operation fails. Asynchronous errors also appear in operation state. Callback exceptions disable the owner and clean up its actions.
- Owner destruction, disable, successful reload or Stop cleans up owned actions and subscriptions. Failed reload retains the previous behavior's operations. See [Operation handles](https://rustic-game-engine.pages.dev/markdown/api/operation-handles.md) for controls and lifetime details.

## Errors and debugging

Read the constraints above and the Console diagnostic. Invalid types, non-finite values, stale targets or unavailable native services can fail validation. A failed callback disables the behavior; a failed source reload keeps the last good instance. Exact error messages depend on the language adapter. See [Troubleshooting](https://rustic-game-engine.pages.dev/markdown/troubleshooting.md).

## Related APIs

- [Animation.clips()](https://rustic-game-engine.pages.dev/markdown/api/animation/clips.md)
- [Animation.load()](https://rustic-game-engine.pages.dev/markdown/api/animation/load.md)
- [Animation.register()](https://rustic-game-engine.pages.dev/markdown/api/animation/register.md)
- [Animation.addMarker()](https://rustic-game-engine.pages.dev/markdown/api/animation/add-marker.md)
- [Animation.play()](https://rustic-game-engine.pages.dev/markdown/api/animation/play.md)

[All animation APIs](https://rustic-game-engine.pages.dev/markdown/api/animation.md)
