public class OnHit : MonoBehaviour
{
private bool hasPackage;
private void OnTriggerEnter2D(Collider2D col)
{
if (CompareTag("Package"))
{
Debug.Log("You have picked up the package!");
hasPackage = true;
Debug.Log(hasPackage);
}
if (CompareTag("Customer"))
{
Debug.Log(hasPackage);
}
}
}
I am decently proficient in Python, so this is really throwing me for a loop and I am stuck.
My bool value of hasPackage defaults back to false and I’m not sure why.
My variable seems to be in the correct position as to not be redefined upon the trigger being executed, but despite that this seems to return false, even though my code looks identical to the one in the video.
Any help would be appreciated, thanks!