Real Time Mirror

27.  Add a Python Controller
  • Logic Editor >> Controllers >> Add Controller >> Python
     
  • Execution Method: Script
Note:
  • Mirror.py is a python script
     
  • You need a Python Controller to run a python script
28.  Select Mirror.py
  • Logic Editor >> Controllers >> Python Controller
  • Script >> Script List >> Mirror.py
Note:
  • Earlier, we opened Mirror.py in the Text Editor
     
  • That added Mirror.py to the game engine's python script list
29.  Add a game property to the mirror
  • Logic Editor menu >> View >> Properties
  • Properties tab >> Add Game Property button
Note:
  • We are adding a game properties that will be used as a variable by the python script.
     
  • This way we can use one (and only one) python script for ALL of the mirrors in the game.
30. Game Property
  • Logic Editor >> Properties tab >> Property Name: material
     
  • Logic Editor >> Properties tab >> Property Type: String
     
  • Logic Editor >> Properites tab >> Property Value: Reflect
Note:
  • Property Name must be named material.  
     
  • The code in Mirror.py looks for a string property named material.
     
  • Reflect is what we named the material.
31.  Connect Logic Bricks
  • Always Sensor >> Python Controller
Note:
  • To connect logic bricks, pull 'wire' from one logic brick output to another logic brick input