Tags vs layers for scene transition collider

@Brian_Trotter ,

out of curiosity can you use a player layer instead of a tag for scene transition portals?

if so are there any major pros and cons to the each solution( especially efficiency, bug resistance, and scalability);

Yes, you could put the Player on it’s own Player layer, and set the Portal’s layer to Portal. Then in the Physics you can make it so that Portal only collides with Player. There’s not actually a downside, just be sure that only the Player has a Player tag.

thanks, the only tweak i ended up doing was swapping out the == for CompareTag . I have no idea if its actually better, but it must exist for a reason, figured id at least give it a go.

private void OnTriggerEnter(Collider other)
{
if (other.CompareTag(“Player”))
{
StartCoroutine(Transition());
}

    }

imo CompareTag is better. Along with the string comparison, it also checks if the tag actually exists in the tags list. That way your inevitable typos will also be caught.

1 Like

Privacy & Terms