Friday, April 8, 2016

Blender BGE: Changing your win scene based on score AND time

You can specify a specific "Win Scene" for your game or level based on the time it takes you to score the necessary number of points for your level.


You can start with the normal logic brick setup:

  • A Property sensor:
    • property is "score"
    • type is "Interval"
    • your minimum and maximum number of points are set as the values of your choice
  • An And controller
  • A Scene actuator
    • mode is "Set Scene"
    • for scene, select your win scene for this time limit
  • All 3 bricks are connected together


Add a 2nd Property sensor:

  • Set the property to "time"
  • The evaluation type is "Less Than"
  • Set the value to the time requirement
  • Connect this new sensor to the "And" controller

If you preview your game, you should go to your win scene if you reach the minimum number of points within this time limit. If you do not, the game will continue running until the player is out of time.

Now we need to add these bricks another time to send the player to a different win scene if they score the required points after the first time limit.

Add:

  • 2 property sensors
    • For the first property sensor:
      • type = Interval
      • property = score
      • set the same minimum & maximum values
    • For the second property sensor:
      • type = Maximum
      • property = time
      • set the same time as before
  • Connect them both to a new "And" controller
  • Connect the "And" controller to a new "Scene" actuator
    • mode = "Set Scene"
    • scene = your win scene for over the first time limit

Now your game should go to different win scenes, depending on the amount of time it takes to reach your score range!