# Animation

Builders can add CSS animations to any object. The most used forms of animations are to let an object move from side to side, up and down or let it rotate.&#x20;

To learn more about animating objects in the Buenoverse, read on, or check out the video tutorial below:

{% embed url="<https://www.youtube.com/watch?v=4OvPec6daXM>" %}

To add animation to an object, go to **Object menu → Interactions → Effects → Animation**

<figure><img src="https://107867006-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdnMYfhsZ5GJTgbm1KIe7%2Fuploads%2Fbl6U0vLgBxqK2MtU9cVR%2Fidle%20enter%20exit.gif?alt=media&#x26;token=3183cbc9-ca33-4d84-85ac-f6a6d62db0a8" alt=""><figcaption><p>Object menu → Interactions → Effects → Animation</p></figcaption></figure>

You can choose the premade animations or make your custom animation using timeframes and basic editing options.

At the top you will see Idle and Enter/Exit;

* Idle; The animation which will play from the moment you enter the room.
* Enter/Exit; The animation will play only if a player enters/exits the [interaction zone](https://docs.bueno.art/buenoverse/fundamentals/elements/interactions#interaction-zone) of an object. (Can set different animations each for enter and exit.)

Once you choose a pre-made or custom animation option you will see that the animation icon is added to the object bar in blue indicating that it is active.

<figure><img src="https://107867006-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdnMYfhsZ5GJTgbm1KIe7%2Fuploads%2FNRkYrQPeo89Bob272XGK%2Fimage%201.jpg?alt=media&#x26;token=96fa165f-07f6-4466-83f9-201697c27fc0" alt=""><figcaption></figcaption></figure>

Once you click on it you will be able to see various options such as;

1. **Remove animation;** removes the animation from the object
2. **Idle - Enter/Exit;** changes between idle and enter/exit mode.
3. **Change animation;** opens the animation selection window.
4. **Edit animation;** opens the edit animation window.
5. **Toggle loop;** if selected activates loop for animations or if not animations play only once.
6. **Edit animation time;** determines how long the animation lasts in seconds
7. **Adjust transform origin;** Let’s you adjust the origin of transform.

<figure><img src="https://107867006-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdnMYfhsZ5GJTgbm1KIe7%2Fuploads%2FavBv551zagouRWado2J7%2Fimage%202.png?alt=media&#x26;token=b09d09c8-ee1b-4b6e-ab2a-fcaba61bc9fd" alt=""><figcaption><p>Animations window</p></figcaption></figure>

**Custom Animations**

If you click on edit animation, the edit animation window will open, there you have some of the same options as well as the timeline option which let’s you create your own animations.

Pressing the Plus Icon beside the Timeline option will add a timeline frame to the list. Then you can start editing the options within a timeline frame in order to create a motion. By adding a timeline frame and editing the movements you can create an animation.

Let’s take a look at some of the options in the timeline.

**Time**: How long does the motion last until it reaches the next frame. It is different from the animation time, where the time of the whole animation is decided.

**Movement**: Adds movement to the directions Up/Down and Left/Right.

**Rotation**: Adds Rotation to the X,Y,Z axes.

**Scale**: Adds scale animation, increasing or decreasing the scale of the object in X and Y axes.

**Skew**: Adds a skew animation to the X and Y axes.

### Let’s see animation in action!

Let's go through a custom animation process step-by-step.

I want this relatively giant spider hanging from the traffic lights to swing side-to-side.

<figure><img src="https://107867006-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdnMYfhsZ5GJTgbm1KIe7%2Fuploads%2FzGZpxf14DJCXXQTQGk4f%2Fbrave_LP7UvNlxIL.png?alt=media&#x26;token=03fc84a2-0468-4b86-9725-bbc23660e4da" alt=""><figcaption><p>That spider looks very frozen right now.</p></figcaption></figure>

We click on our spider and then go to **Interactions → Effects → Animation**

<figure><img src="https://107867006-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdnMYfhsZ5GJTgbm1KIe7%2Fuploads%2FnNqbmZgK5X7yYag35EQw%2Fbrave_Q5AVrKBPHj.png?alt=media&#x26;token=d2496c73-6359-4986-aeea-53b83ef74b1a" alt=""><figcaption><p>Object menu → Interactions → Effects → Animation</p></figcaption></figure>

I want this to be an idle animation so I stay in **Idle** and choose **Custom**.

<figure><img src="https://107867006-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdnMYfhsZ5GJTgbm1KIe7%2Fuploads%2FXZl4lLWKECDsT1MCtRdq%2Fbrave_xVVxdLbqXf.png?alt=media&#x26;token=05409146-5d65-4b44-9c39-a4a8385e1ea9" alt=""><figcaption><p>Choosing custom in idle tab</p></figcaption></figure>

You can now see the animation icon added and active in the **Object menu**. Next we click it and then click the **Edit** button beside the **Custom Animation** in order to open the  **Edit Animation** window.

<figure><img src="https://107867006-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdnMYfhsZ5GJTgbm1KIe7%2Fuploads%2FloHALGpaXovjCbZUEOrv%2Fbrave_tr47GZMXgj.png?alt=media&#x26;token=c4900031-2f2b-4673-9bd3-a7ce161ef1d2" alt=""><figcaption><p>Object Menu -> Animations -> Edit</p></figcaption></figure>

Next we will add a time frame by clicking the **+** icon next to Timeline.

<figure><img src="https://107867006-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdnMYfhsZ5GJTgbm1KIe7%2Fuploads%2FKe4pfus7XP9T5kTqfD7m%2Fbrave_HtuLlxn2ET.png?alt=media&#x26;token=72a284b0-4fb4-48f5-8166-3ea296c4f342" alt=""><figcaption><p>Edit Animation window</p></figcaption></figure>

We want our Spider to swing so first we will start our animation from the right sight.  We click **Rotation** icon, and then choose a value on the **Rotate X** bar in order to move the Spider. You can either use the slider or enter a specific value in the box beside.&#x20;

<figure><img src="https://107867006-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdnMYfhsZ5GJTgbm1KIe7%2Fuploads%2FpFbNlvD47a1zv7TLR34D%2Fbrave_u9ODXyLWZL.gif?alt=media&#x26;token=2c0e7d5e-5f62-4e33-875b-df9e4a4583b2" alt=""><figcaption><p>Adding rotation to the starting frame</p></figcaption></figure>

Our starting frame is done, now our spider will start swinging from the right side. Now we need another frame and enter the exact opposite values to swing our spider to the left. Since this will be a loop there is an easier way to do it. Simply duplicate the frame by clicking the three dots on it's side and then, remove or add "-" to the previously entered values to reverse them.

<figure><img src="https://107867006-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdnMYfhsZ5GJTgbm1KIe7%2Fuploads%2Fy6dZjsAyODnC56PUdKlB%2Fbrave_XEnTp1QuwS.gif?alt=media&#x26;token=d3c2bcfc-4681-4898-bfd3-eb25656909b9" alt=""><figcaption><p>Duplicating the first frame and reversing the values to get a rotation to the left</p></figcaption></figure>

Amazing, now we have spider swinging from right to left. But in order to complete the loop we need it to swing from left to right as well. Again we can either add a new time frame and enter values. BUT the first frame is exactly what we want we don't even need to change the values so let's just duplicate it, and this time simply edit the time to a higher value than our second frame so it is initiated after the second frame.

<figure><img src="https://107867006-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdnMYfhsZ5GJTgbm1KIe7%2Fuploads%2FNxAaGmIzoY8MpCIdUEDy%2Fbrave_7ommGzslEX.gif?alt=media&#x26;token=a3144bae-a556-4eee-b694-9fccb90364f2" alt=""><figcaption><p>Adding our last frame by duplicating the first frame and editing the time value</p></figcaption></figure>

Not bad, but our Spider doesn't look like it is swinging. It looks like it is having a seizure. That's because the **transform origin** is located in the middle as default.  If builders use a rotate animation, they can alter the point of origin. This is point is where the rotation will revolve around. So we need to make the origin the top of the web. Let's click the **Adjust Transform Origin** button and then click on top of the web.

<figure><img src="https://107867006-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdnMYfhsZ5GJTgbm1KIe7%2Fuploads%2F45fq6dnIIshNmEFF23qX%2Fbrave_hvbV7t1pro.gif?alt=media&#x26;token=35a16e84-b0a7-4d12-ae6b-e7a09b084fd0" alt=""><figcaption><p>Adjusting transform origin</p></figcaption></figure>

Our animation is almost complete, the Spider is swinging too fast in my taste, if it keeps going like this It's going to get dizzy.  Let's edit the time values so that it is slower.

<figure><img src="https://107867006-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdnMYfhsZ5GJTgbm1KIe7%2Fuploads%2F5WMNpljywV7y61II6VT9%2Fbrave_DjOIcfFzt2.gif?alt=media&#x26;token=c22a7c78-4e81-4a47-8aa7-f693820e798d" alt=""><figcaption><p>Editing time values</p></figcaption></figure>

Voila! Our Spider is now happily swinging.

<figure><img src="https://107867006-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdnMYfhsZ5GJTgbm1KIe7%2Fuploads%2Fnam3BzlFLeXbkRsCONYx%2Fbrave_pQd9aIay46.gif?alt=media&#x26;token=44c09f81-9ad9-4564-8cf8-55876b10ebdd" alt=""><figcaption><p>Happy swinging spider</p></figcaption></figure>
