35 lines
715 B
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ButtonPlayer:MonoBehaviour
{
public SpriteRenderer spriteRenderer;
public Sprite originalSprite;
public Sprite activatedSprite;
public bool startActivated = false;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (startActivated == true ) {
spriteRenderer.sprite = activatedSprite;
} else {
spriteRenderer.sprite = originalSprite;}
}
void OnTriggerEnter2D(Collider2D other) {
if (other.CompareTag("Player")) {
spriteRenderer.sprite = activatedSprite;
startActivated = true;
}
}
}