How to check if player remains on a path? (2D)

Hello, I am quite new to coding and am developing a top-down mobile game for a college project. The fundament of the game’s mechanic is to navigate a path without walking off it. The whole idea seemed pretty simple at first. Give the player a collider, same with the path objects, then give the path objects a Tag “Platform” and check if the player is ever not in contact with the path. Unity wont seem to take the ! operator for the “if (!col.tag == (“Platform”))”. I tried making a else, statement to check if the player is ever not colliding with the path and it always seems to come up as true.

Any suggestions?

void OnTriggerStay2D (Collider2D col)
	{
		if (!col.tag == "Platform") {

		}

	}

Just to note, I have tried “OnTriggerExit2D”, but it triggers every time I move from one path to the next, even if I never leave a Platform tagged collider.

I also will not place colliders around the entire path, because a lot of the levels get complex and I’d rather just be able to drag and drop my paths into the environment for instant function. As part of this project was to make development streamlined.

I think what you have there is going to try to interpret col.tag as a bool, negate it, and then compare it to the “Platform” string. Try this:

if (col.tag != "Platform")