Second Script

Hi I’ve created a second C# script to handle triggering of another line for delivering the package.

I’ve done it exactly the same as in the example:
public class Customer: MonoBehaviour
void OnTriggerEnter2D(Collider2D other)
{
if(other.tag == “Customer”)
{
Debug.Log(“Package delivered.”);
}
}
It didn’t write anything in the console.

But when I’ve added it to the entire code from the lesson everything was working fine
public class Delivery : MonoBehaviour

{
void OnCollisionEnter2D(Collision2D other)
{
Debug.Log(“Hey I’m printed”);
}
void OnTriggerEnter2D(Collider2D other)
{
if(other.tag == “Package”)
{
Debug.Log(“Package picked up.”);
}
if(other.tag == “Customer”)
{
Debug.Log(“Package delivered.”); }
}
I’m confused right now O.o
This refers to Lesson IF statement from Unity 2D Delivery Driver Project.

Have you added the Customer script to your game object? It might be helpful to see a screenshot of the game object if you can. :slight_smile:

TBH, I forgot about the issue it’s fixed now so I bet I’ve found the issue cheers for the replay tho :smiley:
This is what happens when You are not on top of the course and take like 2 weeks off :stuck_out_tongue:

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

Privacy & Terms