> ## Documentation Index
> Fetch the complete documentation index at: https://wiki.soba.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# How can I loop a behaviour?

> Adding loops to your game will save you a lot of time and will make your game more interactive and dynamic

The concept of looping is essential for creating repetitive actions or effects without cluttering your project with a lot of blocks. A loop efficiently repeats a set of actions indefinitely or for a specified number of times. Let's say that we want an [object](https://sobastudios.mintlify.app/creating-your-game/world-building/place-objects) to spin three times upon interaction.

<Steps>
  <Step title="Select your object">
    <Accordion title="The basics for all behaviors">
      1. Tap on the object to which you want to add a [behavior](https://wiki.soba.xyz/behavior-editor/managing-behaviors/behavior-object)
      2. With the object selected, tap on the “Details” button to the left of your screen.

      <p align="center">
        <img width="200" noZoom src="https://i.imgur.com/jMSZzP8.png" />
      </p>

      3. In the Details panel, tap “Add Behavior”.
    </Accordion>
  </Step>

  <Step title="Set Trigger">
    Choose a trigger of your choice. If you want your action to be triggered by the player interacting with your object, choose the "Interaction" trigger.
  </Step>

  <Step title="Set Controller">
    This is where we add in our loop function. To have the object spin 3 times, go to the “Controllers” section. Select and drag the "N Times" Controllers and drag it below your trigger.
  </Step>

  <Step title="Set Object Action">
    In the “Object Action” section, drag the “Spin” block below your controller block. Adjust the block settings as you wish.

    <Accordion title="Behavior Image">
      <p align="center">
        <img width="200" noZoom src="https://i.imgur.com/HTPcvqp.jpgg" />
      </p>
    </Accordion>
  </Step>

  <Step title="Test Your Game">
    To ensure everything works, playtest your game!
  </Step>
</Steps>
