when the button is released , something happens , how ?

Hi
as in the image , there is a yellow light that flickers as if the character’s gun is shooting
and flickers means (increase the energy value gradiently through time , and does this many times , to mimic more realistic effect)
and actually , i want to make the shooting system as follows
(the right mouse button make the hand aim , and the left mouse button shoots <only if the hand is aiming , … > )
but some would say , (use two logic bricks and (AND) as an expression)
but this wouldn’t be realistic because the user may shoot before aim !!!

so , i want a method to do which follows

((((
when i press space , a property = 1
and at the instance i release the space button the property becomes 0 instantly
))))
i can’t figure out how can i make blender understand that i released a button instead of pressing it , … i’m not sure about the INV button in the sensor , i didn’t check it two much , but is there another solvant ? :o

thanks :smiley:

Attachments


INV detect when the key is released if I remember well, or use python I know there’s a “when the key is released” function in there : http://www.tutorialsforblender3d.com/GameModule/GameKeys.html

thanks micro , i will try it , … :slight_smile:
guys is there another way ?

I’m sorry but it kinda seems like you’re contradicting yourself there? In the beginning it seems you only want the player to be able to shoot only if he’s aiming (Which works perfectly with ANDing them together). Then later you say he could shoot before aiming.

So which one is it that you want?

Jason Lin

I think he meant that the player might accidentally shoot before aiming, and that he does not want that to happen.

GURU, to answer your question about the spacebar, you must use Python.

When the player first presses a key, the keyboard sensor sends a positive pulse which triggers the controller with a value of “TRUE”.

If you have “TRUE level triggering (pulse mode)” button enabled, then the keyboard sensor will trigger the controller every logic tic (every frame) or at the tic rate you specified in the sensor’s “f:” field (“f: 0” means every frame).

When the player releases the key, the keyboard sensor sends a negative pulse, which triggers the controller with a value of “FALSE”.

Here is the script you need to use:

cont = GameLogic.getCurrentController()
own = cont.getOwner()

spacebar = cont.getSensor("Spacebar")  # This is a keyboard sensor named Spacebar

if spacebar.isPositive():  #The Python controller received a TRUE signal
     # The player has just pressed the spacebar.  Put the code you want here.

if not spacebar.isPositive():  #The Python controller received a FALSE signal
     # The player has just released the spacebar.  Put the code you want here.

This will also work for the mouse sensor.

I think he meant that the player might accidentally shoot before aiming, and that he does not want that to happen.
Exactly blendenzo :slight_smile:
Hey , blendenzo , your method is the better one :slight_smile: , i have tried it :slight_smile:
thanks enzo , and thanks for micro27 , and thanks all :slight_smile:
i’m just learning python , so a python noob :slight_smile:

Couldn’t you also have an ALWAYS sensor setting your property to 0 and the MOUSE sensor setting it to 1? As long as the logic bricks for the mouse are below the ALWAYS sensor it will be the priority.

Couldn’t you also have an ALWAYS sensor setting your property to 0 and the MOUSE sensor setting it to 1? As long as the logic bricks for the mouse are below the ALWAYS sensor it will be the priority.

wew @_@ ! , … i thought this wouldn’t work before , but tried it and it is too simple and it works :slight_smile:
i have now 3 methods :slight_smile: