Always Unless...

Is there a way to make a sensor that is Always, unless another specific sensor is activated?

For instance, Always play animation unless Keyboard sensor is activated.
When Keyboard sensor deactivated, the Always sensor turns on again.

:confused: Im not sure about that one -
But you can definantly write a small code in python to do it. Im not a master of code so i probley cant help you out.

of an armature, I just set the always---->and----->action (priority:1) and set all the other animations prioritys higher than 1. sorry if that doesn’t make sense…

Ya. it’s no problem :smiley: just have the always sensor conected to the controller ‘and’. then connect a property sensor to ‘and’ as well. For the property sensor, in the fields, you want it to activate when ‘property’ = w/e number you want. i prefer 1 and 0 (on and off). give the object the property ‘property’ (or whatever you want to put; just be sure the property name is the same in the sensor and for the actual property name!) then, this sensor is only active when property = 1, say. Then for your other one, make it the same way, only the set it to activate on w/e (keyboard, always, mouse) and when the property is 0. Since the property can’t be 0 and 1 at the same time, only one can be active at any given time! I’ll leave the rest up to you (heres a hint: you have to set up the other sensor to change the property; think about using an inv sensor).

You can PM if you want a blend or something.

What I would do is make a Bool Property called “KeyPress”

Basically, when you press the key, it makes KeyPress True (via logic bricks)
now when you release the key, it makes the KeyPress False (just invert the key sensor).

Now your animation setup would be (logic bricks):

always…expression: KeyPress = True…play animation

see the attachment


animationhold.blend (132 KB)

2 options:

Use the “inv” button on the keyboard sensor, and hook that sensor, along with the always, to an “and” controller. The Inv setting makes that sensor continually fire pulses only when the key is NOT pressed, and it won’t send pulses when the key IS pressed. You’ll have to have 2 keyboard actuators if you want the keypress to do something else as well, one without the “inv” option selected.

If you only have the keyboard sensor and the always sensor hooked up, you could use a “XOR” controller. XOR, aka exclusive or, only will activate when ONE of the settings is true. This means that if only the always sensor is sending pulses, it’ll go through, but when the keyboard sensor is being activated, it’ll have 2 pulses being thrown at it and it won’t go through. Note that no matter how many sensors are attached, the controller will only activate when ONE is active.

Here’s a basic blend file to show these basic methods. state 1 uses XOR, state 2 uses an inverted keyboard sensor.


notKeyPress.blend (31.4 KB)

ahh I never thought of that :wink:

I forgot the new xor feature but both ways would work