Holding a key.

Ya I know the title seems stupid, but it’s not what you think…I think. I have animations for an object, one called Idle and one called Run. What I want to do is when I hold W, A, S, or D, I want it to play the Run animation. So that works all fine, but once I let go of any of those keys, it keeps playing the animation. I used a property to maybe make it easier to solve this problem. Basically it’s a boolean and when true, it shows the Run animation. A quick summary below.

What I want to happen:
I hold one of those keys (Or 2 at the same time.) and that should change it to True. I let go of both, and then it changes back to False.

What happens:
I start at False, and then press one of those keys. It goes to True, but when I let go it stays at True.

Thanks in advance!

there are actuators that you can use to set properties, but I think an easier way to do it would be to edit the property in a python script.

something like:

if not sen.isPositive():
own.playanim = 0

An example file might help us solve this particular problem BUT…

You can have 2 seperate sensors, one for the keypress, and then one with the same keypress but the “inv” button pressed. This basically means the sensor will fire pulses only when it’s NOT pressed.

I attached a basic example. Take a look.

Attachments

basicexample.blend (116 KB)

it’s much easier than you think. My method includes an always sensor on pulse mode though…

WASD sensors = and controllers = motion actuator, and play action “Run” priority “0”.
Always sesnors = and controller =play Idle action priority “1” also, mess with the blendin function on this actuator.