Another – Day 3 – Recap

After showing a friend the debug boxes from Day 2, he suggested that I could set each box to toggle a single value. Previously I was attaching a script to each box that could toggle on one set of data while toggling off another.

I call this new approach Boolean Cubes.

  • A Game Manager script with a property containing an object, each key representing a boolean value for something in the scene. I’m calling these “bits” but really this is just a JavaScript object with a bunch of boolean properties.
  • A debug script with a single attribute: bitToFlip. When a bullet hits one of these cubes, it will run an event and toggle the corresponding value in the Game Manager.
  • The scripts that manage the game logic for the target objects check the values of certain bits in the Game Manager.

This gives me one place to store the current state of the game. I can trigger these while in VR to test different combinations, and I can run them with keyboard shortcuts from meatspace.