---
contentHash: sha256:fc53cf82a926b27bd9759b2054f86a438904b6fcccf38bc9cb3ac4d8cabd142c
documentId: guide:for-agents-example-constraints
kind: guide
schemaVersion: 1
skenraVersion: 0.1.0-alpha.1
---
# Constraints

<a id="overview"></a>

## Overview

Two constraint kinds: an orbit constraint carries a moon around a planet (the azimuth keyframes live INSIDE the constraint, because the constraint owns the animated property), and a target-at constraint keeps an arrow aimed at the moving moon.

Choosing a motion pattern: if the scene DRAWS the path, use an align-to-spline constraint and animate progress (0 to 1); if the motion is invisible and circular, animate an orbit constraint's azimuth (never the node's own h rotation).

Demonstrates: orbit constraint, animated constraint property, target-at.

<a id="scene"></a>

## Scene

```sk
<sk-scene style="width: 100%; height: 420px;">
    <sk-camera-orbit-control fit-targets="auto" fit-margin="0.2"
        azimuth="30deg" elevation="26deg" orient-toward-pivot></sk-camera-orbit-control>
    <sk-perspective-camera focal-length="26"></sk-perspective-camera>
    <sk-directional-light intensity="1" p="70deg" h="30deg"></sk-directional-light>

    <sk-plain-material id="planet-mat" base-color="#4a7a9e"></sk-plain-material>
    <sk-plain-material id="moon-mat" base-color="#d8d0c0"></sk-plain-material>
    <sk-plain-material id="arrow-mat" base-color="#c05a4e"></sk-plain-material>

    <sk-sphere id="planet" radius="1.2">
        <sk-surface-paint material="#planet-mat"></sk-surface-paint>
    </sk-sphere>

    <!-- The animation lives INSIDE the constraint: azimuth is the
         constraint's property, so the constraint owns the keyframes. -->
    <sk-sphere id="moon" radius="0.5">
        <sk-surface-paint material="#moon-mat"></sk-surface-paint>
        <sk-orbit-constraint radius="3" elevation="18deg">
            <sk-animation duration="8000ms" iterations="Infinity" easing="linear">
                <sk-keyframe offset="0" azimuth="0deg"></sk-keyframe>
                <sk-keyframe offset="1" azimuth="360deg"></sk-keyframe>
            </sk-animation>
        </sk-orbit-constraint>
    </sk-sphere>

    <!-- A second constraint kind: keep the arrow aimed at the moving moon. -->
    <sk-arrow y="2.6" shaft-length="1" head-length="0.35" head-radius="0.22"
              rotation-segments="24">
        <sk-surface-paint material="#arrow-mat"></sk-surface-paint>
        <sk-target-at-constraint target="#moon" axis="+y"></sk-target-at-constraint>
    </sk-arrow>
</sk-scene>
```

---

Related records: [`element:sk-animation`](elements/sk-animation.md), [`element:sk-arrow`](elements/sk-arrow.md), [`element:sk-camera-orbit-control`](elements/sk-camera-orbit-control.md), [`element:sk-directional-light`](elements/sk-directional-light.md), [`element:sk-keyframe`](elements/sk-keyframe.md), [`element:sk-orbit-constraint`](elements/sk-orbit-constraint.md), [`element:sk-perspective-camera`](elements/sk-perspective-camera.md), [`element:sk-plain-material`](elements/sk-plain-material.md), [`element:sk-scene`](elements/sk-scene.md), [`element:sk-sphere`](elements/sk-sphere.md), [`element:sk-surface-paint`](elements/sk-surface-paint.md), [`element:sk-target-at-constraint`](elements/sk-target-at-constraint.md), [`guide:for-agents`](guides/for-agents.md)
