Search code examples
unity-game-enginesprite

How do you trigger a script after passing a sprit in unity


In unity I want to trigger a camera follow script after the player passes a certain sprit in unity but I don't know if there is a component you could use on a sprit or something like that.


Solution

  • Im guessing you are referring to a sprite, if thats the case, just add a colider2D to the sprite and use onTriggerEnter2D() to check when the colider on your character touches the collider on your other object with something like this:

    void OnTriggerEnter2D(Collider2D col)
    {
        Debug.Log("I touched the sprite");
    }