I have a noo…(I really hate this word), beginners question. How do I switch the values of a property with the same key? For example, I press SPACE to set a Boolean property to False, and press it again to set it back to True.
try setting up a keyboard sensor and a property sensor set to true to a controller then connect that controller to one that sets the property to false. Next connect the keyboard sensor and a property sensor set to false to a second controller which is connected to a property actuator that sets the property to true
kind of like this:
if Property false --> controller (and) —> set property true
keyboard —^
if property true ----> controller (and)—>set property false
keyboard --------------^
hope that helps!
Hehe, also another way and a bit shorter.
Say you have a boolean property named “value”.
Space->AND->Property(Prop: value, Value: !value)
Have fun
Jason Lin
Hello
these little tips are quite useful
And, how to change the property only when the key is pressed and back to
first state when the key is released
Thanks
You can use isPositive() for when the key is pressed. So something like:
if sensor.isPositive():
owner.value = 1
else:
owner.value = 0
ha goldentaiji i didnt know that i ususlly use expressions
I’ve tried zoel’s idea before, but it didn’t really work properly. See its like when you press a key for a character to get into a car and take control of the car, and press it again to re-take control of the character. See I know how to use properties; its just that I’m stumped on this particular problem.
Thanks fireside