Skip to main content
4 events
when toggle format what by license comment
Jul 18, 2022 at 13:20 comment added DMGregory I think you can make this script more generic by scrubbing out references to "room1" - use a UnityEvent to allow the level designer to link up this one-time collider trigger to any outcome method they want. Then they can re-use the same script to trigger the jump scare in room 1, to trigger a door opening in room 2, to cue the music change in room 5, etc.
Jul 18, 2022 at 9:55 comment added PepeOjeda Well, yes. I guess it's a very subjective thing, but I find explicitly initializing the variable is more pleasing than relying on the default value. Also, I don't like setting the value of class members in the declaration because if at some point you serialize the variable it can get very confusing (when the serialized value does not match the initialization in the script). But yes, in this case, both of those do indeed work.
Jul 18, 2022 at 9:31 comment added Philipp The Start method is unnecessary here, because bool variables automatically get initialized as false. And even if you want to initialize a variable to a specific value, you can do that when you declare it (bool playerHasNotBeenInRoom = true).
Jul 18, 2022 at 9:16 history answered PepeOjeda CC BY-SA 4.0