Skip to main content
1 of 2
Tomo
  • 133
  • 4

How to make the player pass through only certain objects, but not others?

Experimenting with my 1st Unity project. It's about a top down swimmer. By toggling the swimmer's collider, he can swim under boats:

if (Input.GetKeyDown(KeyCode.A)) swimmerCircleCollider.enabled = !swimmerCircleCollider.enabled; 

At the same time I don't want him to be able to swim under the wharf, which is like an uncrossable barrier/border/wall or simply the end of playable area. How can I achieve that?

Is the idea of disabling the collider wrong in the first place? If so, please provide some guidelines for a better solution.

Tomo
  • 133
  • 4