> For the complete documentation index, see [llms.txt](https://roxioxx.gitbook.io/unity-cookbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://roxioxx.gitbook.io/unity-cookbook/ui-onlyfans/interactible-game-objects/interactible-marker.md).

# Interactible Marker

Working File:

<figure><img src="/files/2dlGm3yT5f2l7kxXodrC" alt=""><figcaption></figcaption></figure>

## Setup

Change the color of the static sprite to have 0 Alpha. Remove the Rigidbody2D and click on "Is Trigger." Edit the collider so that it accurately tells the range.

<figure><img src="/files/XoH9og0qe2PFK5phL7YT" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/0Tm6lpagIkF8kZtdF6vI" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/7sCi3f9hLXm1kFUNbSXf" alt=""><figcaption></figcaption></figure>

Now, just drag that UI sprite for the marker to the location you want it in the scene.

<figure><img src="/files/WkEDfxZhdR5mJ6eHkE2l" alt=""><figcaption></figcaption></figure>

Then, make that marker sprite a child of the Interactible object.

<figure><img src="/files/gKbnjb8I0rrQPwierBtZ" alt=""><figcaption></figcaption></figure>

## Coding the Script

This is going to be very simple. We will simply enable the marker when the player enters the trigger zone. You want to attach this below script to the Interactible gameObject in the scene.&#x20;

```csharp
using UnityEngine;

public class InteractibleMarker : MonoBehaviour
{

    [SerializeField] private GameObject marker;

    private void Start()
    {
        marker.SetActive(false);
    }

    //Upon collision with another GameObject
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.CompareTag("Player"))
        {
            marker.SetActive(true);
        }
    }

    private void OnTriggerExit2D(Collider2D other)
    {
        if (other.gameObject.CompareTag("Player"))
        {
            marker.SetActive(false);
        }
    }

}
```

Then, from the inspector, pull the marker sprite into the script component.

## Animation

Depending on the style, you may want the marker to move. With the marker sprite selected in the scene hierarchy, create a new animation. Go to the time you want the thing to change, and add transform property. Create a new keyframe with the changed values. If needed, use the dopesheet to make sure it is undulating correctly.

## Make a Prefab

Now, we can simply drag this as a child of the gameObjects and have it do all the same stuff all over again.

To make a prefab, pull that newly created gameObject in the scene view and pull it into the projects window of the folder of your choosing. I created a "Prefabs" folder.

<figure><img src="/files/QDW5jLcscAbLGGCMNa5v" alt=""><figcaption></figcaption></figure>
