Hi all,
First time posting and still very new to Unity, so please be kind
I’m trying to have the text box sprite appear and disappear based on whether or not the player (Banana) has collided with the sign post. Please see the attached image:[164706-capture.png |164706]
Here is the code that I have written:
public class PopUpImage : MonoBehaviour
{
public SpriteRenderer popUp;
private void Start()
{
popUp = GetComponent<SpriteRenderer>();
}
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.CompareTag("Player"))
{
popUp.enabled = false;
}
}
private void OnTriggerExit2D(Collider2D collision)
{
if (collision.CompareTag("Player"))
{
popUp.enabled = true;
}
}
I set the Sprite Render to be the text box (CollisionText1) but when I touch the sign post, the post disappears and reappears instead of the Text Box Sprite.
Would anyone know why this might be the case?
Thanks in advance!