OnTriggerEnter2d wont work

I have a rigid body and a Player tag on my guy, and the finish pole has a trigger but for some reason the script won’t work

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class Finish : MonoBehaviour

{

void OnTriggerEnter2D(Collider2D other)

{

    if(other.tag == "Player")

    {

        Debug.Log("you win");

    }    

}

}

Hi Robo15,

Does the finish pole also have the Finish script attached to its Inspector? And are the messages enabled in your console?

If so, I would suggest to rewatch the video at least one more time. Maybe a detail is missing in your project.


See also:

Oh, I fixed it apparently I needed to tag my head collider. Thanks for responding though!

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

Privacy & Terms