0
\$\begingroup\$

Im trying to create an Animated Waterfall Tilemap from a tutorial video.

enter image description here In his video when the author right clicks he can see a Animated Tile > under CREATE option.

But In my case its not there !! Please see picture below. enter image description here

\$\endgroup\$
3
\$\begingroup\$

Just download this script AnimatedTile and put it into your project, then you can find AnimatedTile at Create > Tiles > Animated Tile.

In case you don't want to click the link, I copy the script for you

using System;

#if UNITY_EDITOR
using UnityEditor;
#endif

namespace UnityEngine.Tilemaps
{
    /// <summary>
    /// Animated Tiles are tiles which run through and display a list of sprites in sequence.
    /// </summary>
    [Serializable]
    [CreateAssetMenu(fileName = "New Animated Tile", menuName = "Tiles/Animated Tile")]
    public class AnimatedTile : TileBase
    {
        /// <summary>
        /// The List of Sprites set for the Animated Tile.
        /// This will be played in sequence.
        /// </summary>
        public Sprite[] m_AnimatedSprites;
        /// <summary>
        /// The minimum possible speed at which the Animation of the Tile will be played.
        /// A speed value will be randomly chosen between the minimum and maximum speed.
        /// </summary>
        public float m_MinSpeed = 1f;
        /// <summary>
        /// The maximum possible speed at which the Animation of the Tile will be played.
        /// A speed value will be randomly chosen between the minimum and maximum speed.
        /// </summary>
        public float m_MaxSpeed = 1f;
        /// <summary>
        /// The starting time of this Animated Tile.
        /// This allows you to start the Animation from a particular Sprite in the list of Animated Sprites.
        /// </summary>
        public float m_AnimationStartTime;
        /// <summary>
        /// The Collider Shape generated by the Tile.
        /// </summary>
        public Tile.ColliderType m_TileColliderType;

        /// <summary>
        /// Retrieves any tile rendering data from the scripted tile.
        /// </summary>
        /// <param name="position">Position of the Tile on the Tilemap.</param>
        /// <param name="tilemap">The Tilemap the tile is present on.</param>
        /// <param name="tileData">Data to render the tile.</param>
        public override void GetTileData(Vector3Int location, ITilemap tileMap, ref TileData tileData)
        {
            tileData.transform = Matrix4x4.identity;
            tileData.color = Color.white;
            if (m_AnimatedSprites != null && m_AnimatedSprites.Length > 0)
            {
                tileData.sprite = m_AnimatedSprites[m_AnimatedSprites.Length - 1];
                tileData.colliderType = m_TileColliderType;
            }
        }

        /// <summary>
        /// Retrieves any tile animation data from the scripted tile.
        /// </summary>
        /// <param name="position">Position of the Tile on the Tilemap.</param>
        /// <param name="tilemap">The Tilemap the tile is present on.</param>
        /// <param name="tileAnimationData">Data to run an animation on the tile.</param>
        /// <returns>Whether the call was successful.</returns>
        public override bool GetTileAnimationData(Vector3Int location, ITilemap tileMap, ref TileAnimationData tileAnimationData)
        {
            if (m_AnimatedSprites.Length > 0)
            {
                tileAnimationData.animatedSprites = m_AnimatedSprites;
                tileAnimationData.animationSpeed = Random.Range(m_MinSpeed, m_MaxSpeed);
                tileAnimationData.animationStartTime = m_AnimationStartTime;
                return true;
            }
            return false;
        }
    }

#if UNITY_EDITOR
    [CustomEditor(typeof(AnimatedTile))]
    public class AnimatedTileEditor : Editor
    {
        private AnimatedTile tile { get { return (target as AnimatedTile); } }

        public override void OnInspectorGUI()
        {
            EditorGUI.BeginChangeCheck();
            int count = EditorGUILayout.DelayedIntField("Number of Animated Sprites", tile.m_AnimatedSprites != null ? tile.m_AnimatedSprites.Length : 0);
            if (count < 0)
                count = 0;

            if (tile.m_AnimatedSprites == null || tile.m_AnimatedSprites.Length != count)
            {
                Array.Resize<Sprite>(ref tile.m_AnimatedSprites, count);
            }

            if (count == 0)
                return;

            EditorGUILayout.LabelField("Place sprites shown based on the order of animation.");
            EditorGUILayout.Space();

            for (int i = 0; i < count; i++)
            {
                tile.m_AnimatedSprites[i] = (Sprite) EditorGUILayout.ObjectField("Sprite " + (i+1), tile.m_AnimatedSprites[i], typeof(Sprite), false, null);
            }

            float minSpeed = EditorGUILayout.FloatField("Minimum Speed", tile.m_MinSpeed);
            float maxSpeed = EditorGUILayout.FloatField("Maximum Speed", tile.m_MaxSpeed);
            if (minSpeed < 0.0f)
                minSpeed = 0.0f;

            if (maxSpeed < 0.0f)
                maxSpeed = 0.0f;

            if (maxSpeed < minSpeed)
                maxSpeed = minSpeed;

            tile.m_MinSpeed = minSpeed;
            tile.m_MaxSpeed = maxSpeed;

            tile.m_AnimationStartTime = EditorGUILayout.FloatField("Start Time", tile.m_AnimationStartTime);
            tile.m_TileColliderType=(Tile.ColliderType) EditorGUILayout.EnumPopup("Collider Type", tile.m_TileColliderType);
            if (EditorGUI.EndChangeCheck())
                EditorUtility.SetDirty(tile);
        }
    }
#endif
}
| improve this answer | |
\$\endgroup\$
4
\$\begingroup\$

If you are talking about the Random and Animated Tilemap Tiles tutorial available in the Unity website, then, you simply need to download and import the provided source below the video....

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Thanks for reply. but im not referring to premade prefab. I want to create my own animated tile as shared in first screenshot. \$\endgroup\$ – STEEL Dec 20 '18 at 14:55
  • 1
    \$\begingroup\$ The package contains scripts needed in order to display the Animated Tile option in the Create menu. \$\endgroup\$ – Hellium Dec 20 '18 at 15:35
  • \$\begingroup\$ thanks it worked. I didn't knew thats how you install Unity plugins. \$\endgroup\$ – STEEL Dec 20 '18 at 15:39
  • \$\begingroup\$ Hey just wanted to know how to add those scripts to tilemap beginner here! \$\endgroup\$ – user128883 May 28 '19 at 18:12
1
\$\begingroup\$

I had the same problem, and found the answer here: http://shadowpeakstudios.com/2018/10/22/unity-tutorial-animated-tiles/

Basically for it to work you have to download the 2d-extras from here: https://github.com/Unity-Technologies/2d-extras

Steps:

  1. Download the 2d-extras
  2. Extract the zip, then drag the "2d-extras-master" folder into your "Assets" folder in Unity
  3. Create a new tilemap: Right-Click in Hierarchy > 2D-Object > Tilemap
  4. Then right click on your "Assets" folder: Create > Tiles > Animated Tile (will finally show up)

Aniamted Tile Map

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ This works in Unity 2019.3. For me the path to the Animated Tile is Create > 2D Extras > Tiles then. \$\endgroup\$ – Kai Hartmann Jul 4 at 19:23
0
\$\begingroup\$

you will find it under the "Tile" tab in the menu. check your picture , you will find "Tile"

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ your answer can be more complete with an image or more explanation. \$\endgroup\$ – virtouso Sep 19 '19 at 19:39
0
\$\begingroup\$

this is an additional answer for those encountering this issue currently (March 2020). The github link has updated quite a bit since the creation of the udemy guide. I solved my issue with this by going to the github link the asker posted. Then on the branch selector (the button on the far left of the clone/download button), change the branch from "master" or whatever it currently is to 2018. You would then have the similar tools that the author of the guide wants you to download.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ I don't see any link to github in the question, what link are you referring to? \$\endgroup\$ – Vaillancourt Apr 3 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.