Problem with the hasPackage (hasPizza in my example)


So my problem is when I take the pizza, I got the message correctly. However, when I try to deliver to my customer, I can’t get the message also. And by the way when I delete hasPizza in Customer if statement, it’s works normally (second image). Thanks.

The reason it doesn’t work is because you set hasPizza on the pizza you just picked up. Then you deliver to a customer, but that customer is not the pizza, so hasPizza on the customer is still false.
This script should be on the player, not on the pizza or customers. I assume this to be the case because you are looking at this.tag meaning this current object’s tag. If this script is on the player, those would never be true and you will never see the messages. This also means those checks need to change to other.tag == "Pizza" or better even other.CompareTag("Pizza")

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms