using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class wwew : MonoBehaviour
{
[SerializeField] Sprite newSprite;
// newSprite = the Sprite you wish the original player sprite to change into when Triggered
[SerializeField] Sprite newSprite2;
// newSprite2 = the original player sprite
[SerializeField] float destroyDelay = 0.1f;
bool hasPackage;
SpriteRenderer myspriteRenderer;
// void ChangeSprite()
//{
//spriteRenderer.sprite = newSprite;
//}
void Start()
{
myspriteRenderer = gameObject.GetComponent<SpriteRenderer>();
}
void OnCollisionEnter2D(Collision2D other)
{
Debug.Log("OMG");
}
void OnTriggerEnter2D(Collider2D other)
{
if(other.tag == "Package" && !hasPackage)
{
Debug.Log("Picked up");
myspriteRenderer.sprite = newSprite;
hasPackage = true;
Destroy(other.gameObject, destroyDelay);
}
if(other.tag == "Customer" && hasPackage)
{
Debug.Log("Delivered");
myspriteRenderer.sprite = newSprite2;
hasPackage = false;
}
}
}