Restricting walkability

Hi,

I am making a top down 2D game with a sprite that can walk over a background. I am using the free version of Unity 4.3. I want to prevent the sprite from walking over some irregular shaped areas. Think of a pond, for example. I thought, I could put 2d colliders around the pond to prevent the sprite from entering, but it will be tough to approximate the shape of the pond. I also thought I could use tiles, or maybe a grid that breaks down the background image into zones, which I could check before moving.

Anyone solved this in a clean and simple way?

can you not use a polygon collider on the lake? it should shape itself…

That could totally work, I didnt even know about it. Thanks!

Not only can you use the 2D polygon colider, but you can even customize the shape if the default doesn’t work for you. Use the shift and control keys to add and subtract vertices from the colider, and make it as simple or complex as is needed.