How would I go about making a 2d darkness system which would make my game dark, I want the darkness to be dangerous so there are monsters but only in the dark and where is bright is a safe spot
You can place lights around the level and have the monsters avoid them by checking their distance to any nearby lights. Although I’m guessing you’re new to programming and so perhaps you could add an area effector to the lights that push the monsters away from them.
Zulo, you continue to delight me with new ways to simply combine two things in Unity that I NEVER would have considered before. This approach might be extremely useful for OP’s “keep monsters away from light” feature, and it is incredibly simple to test. Bravo.
As for OP: you can use layers and layermasks to control what such an AreaEffector2D impacts.
sorry for the late reply, I think this is still pretty complex feature to make for me at least but I at now know how to go about it, I guess I need to make some simple enemy ai that will avoid the light, maybe a method that says if you touch the light run away from it would work, how do I program it so it doesn’t detect the player if he is in the light, one of my enemies has a big trigger/collider that checks where the player is and runs at them, I want the trigger to not trigger if the player is in the light
If using an area effector then you won’t need to do any programming. The area effector can be set to push or pull rigidbodies away from its center. So an area effector on the lights would be set to push the monsters away. And the area effector on the player can be set to pull the monsters towards the player. If the player is near a light then the monsters will be pushed and pulled at the same time resulting in the monsters staying where they are, waiting and drooling…