Last active
December 14, 2021 04:35
-
-
Save satishgoda/5682945 to your computer and use it in GitHub Desktop.
This gist was a result of an answer I posted at blender.stackexchange.com (http://blender.stackexchange.com/questions/461/how-to-set-a-property-value-in-blender-game-engine/501#501)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bge | |
controller = bge.logic.getCurrentController() | |
sensor = controller.sensors['up_WKEY'] | |
if sensor.getKeyStatus(bge.events.WKEY) == bge.logic.KX_INPUT_JUST_ACTIVATED: | |
owner = controller.owner | |
actuator = controller.actuators['upkeycount'] | |
actuator.value = str(owner.get(actuator.propName) + 1) | |
controller.activate(actuator) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bge | |
controller = bge.logic.getCurrentController() | |
sensor = controller.sensors['up_WKEY'] | |
event = sensor.events[0] | |
key, status = event | |
if key == bge.events.WKEY and status == bge.logic.KX_INPUT_JUST_ACTIVATED: | |
owner = controller.owner | |
actuator = controller.actuators['upkeycount'] | |
actuator.value = str(owner.get(actuator.propName) + 1) | |
controller.activate(actuator) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bge | |
controller = bge.logic.getCurrentController() | |
sensor = controller.sensors['up_WKEY'] | |
if [bge.events.WKEY, bge.logic.KX_INPUT_JUST_ACTIVATED] in sensor.events: | |
owner = controller.owner | |
actuator = controller.actuators['upkeycount'] | |
actuator.value = str(owner.get(actuator.propName) + 1) | |
controller.activate(actuator) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bge | |
controller = bge.logic.getCurrentController() | |
sensor = controller.sensors['up_WKEY'] | |
pairs = [] | |
pairs.append([bge.events.WKEY, bge.logic.KX_INPUT_JUST_ACTIVATED]) | |
pairs.append([bge.events.WKEY, bge.logic.KX_INPUT_ACTIVE]) | |
go = any([pair in sensor.events for pair in pairs]) | |
if go: | |
owner = controller.owner | |
actuator = controller.actuators['upkeycount'] | |
actuator.value = str(owner.get(actuator.propName) + 1) | |
controller.activate(actuator) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bge | |
controller = bge.logic.getCurrentController() | |
sensor = controller.sensors['up_WKEY'] | |
inputStatuses = [bge.logic.KX_INPUT_JUST_ACTIVATED, bge.logic.KX_INPUT_ACTIVE] | |
pairs = list(zip([bge.events.WKEY]*len(inputStatuses), inputStatuses)) | |
go = any(list(list(pair) in sensor.events for pair in pairs)) | |
if go: | |
owner = controller.owner | |
actuator = controller.actuators['upkeycount'] | |
actuator.value = str(owner.get(actuator.propName) + 1) | |
controller.activate(actuator) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Blender Demo : Game Engine : Logic Bricks + Python Side-by-Side
http://www.youtube.com/watch?v=UL0_I7iFlbU