using System.Collections; using System.Collections.Generic; using UnityEngine; public class SwitchSprite : MonoBehaviour { public bool inRange = false; public Sprite[] sprites; private List availableSprites = new List(); // Start is called before the first frame update void Start() { availableSprites.Add(1); } // Update is called once per frame private void OnTriggerEnter2D(Collider2D collision) { if (collision.tag == "Player") { inRange = true; } } private void OnTriggerStay2D(Collider2D collision) { if (collision.tag == "Player") { inRange = true; } } private void OnTriggerExit2D(Collider2D collision) { inRange = false; } void Update() { if(inRange == true) { if(Input.GetKeyDown(KeyCode.E)) { GetComponent().sprite = sprites[0]; } } } }