I am working on a 2D top-down game. (Camera view is similar to The Binding of Isaac), and I want to create an invisible area behind objects (2D sprites), in order to restrict player’s visibility, like in this sketch. I have no idea how to start, I can’t use 3D objects.
Top tip: always check the Asset Store.
Maybe you can try using a trigger. This is just an example
var target : Collider; //this is the variable that will hold the colliding object
private var triggered : boolean = false; //If we only want to detect the first time it's triggered
function OnTriggerEnter(collision : Collider)
{
if (collision != target) //The colliding object isn't our object
{
return; //don't do anything if it's not our target
}
triggered = true; //If you want to have this only trigger once
//Other code to do stuff on trigger goes here. You could:
// 1. Increase a variable to keep track of score
// 2. Transform the colliding object (send the player flying, etc)
// 3. Play a sound (audio.Play() if you have an audio source)
// 4. And much, much more
}