I am making a shooter game and i have a single shot weapon for which i am using a muzzle flare(which is basically a plane with a muzzle flash texture with an alpha channel), what i want is for it to flash on and off quickly when i press the left mouse button. i already have one LMB sensor with Tap enabled, this sensor is connected to one AND gate and one NAND gate, the AND is connected to a visibility actuator which makes the flash visible and the NAND is connected to a visibility actuator which makes the flare invisible, in theory there should be a single, quick pulse which makes the flash visible for an instant, then turns it off, but when i run the game and press Left Mouse Button, i don’t see the flare at all, does anyone know why this might be?
Not at all. You are sending both at the same exact time and they are canceling each other out. What you want is to do is put the lamp in a separate layer and use the add object actuator to spawn it in. Make sure the add object actuator time value is set to 1 so that the light only exists for 1 logic brick before it removes itself.
here is a screenshot, they should not be triggered at the same time because one is an AND and the other is a NAND so when a short positive pulse is sent, the AND gate will be activated, when the short positive pulse stops the NAND is triggered by a negative pulse.
This is incorrect. When using Tap mode, the sensor it triggered for two consecutive frames when the button is pressed. The sensor’s state is True on the first frame and False on the second regardless of whether the key has been released. TimDrew’s current setup should work fine provided he has everything else setup correctly.
Like i said, they are cancelling each other out since both are being executed within the same logic tick. The method i stated above does not require as many logic bricks and is more efficient. Just because they are different controllers does not mean that they are executed at different times. 1 logic tick is equal to one full cycle through the entire logic stack.
Yes, both controllers are evaluated each frame, but they do not simultaneously activate their respective actuators.
The state of the sensor is True on the first frame, so the AND controller will activate its actuator while the NAND controller will not. On the second frame the sensor is False, so the NAND controller activates its actuator while the AND controller does not.
So yes, they ultimately cancel out each other but it takes an additional frame to do so, which is what the OP said he wanted.
ive tried what he said and it doesnt show up at all which is the original problem. also, the logic tick rate is faster than the framerate (and on purpose).
It works fine for me. I generally use “frame” and “logic-tick” synonymously.
The higher logic-tick rate only applies when the BGE experiences slow down. I prefer to think of it as frame-dropping because that’s what it does. If Max Logic Steps is > 1, the BGE will skip rending if everything that needs to happen in a frame is taking too long. The BGE will drop a maximum of 4 frames before rending when using the default Max Logic Step value of 5.
This is almost certainly the problem OP is experiencing, especially since he said it occurred more frequently in his original (more complex) file. The muzzle flash is being made visible and invisible on separate logic-ticks, but he does not see it because the frame the flash would be rendered is dropped due to slow down.
Setting Max Logic Steps (under World -> Physics) to 1 will prevent any frames from being dropped and should fix the problem in this case.
The visibility actuator does nothing on deactivation. If it receives multiple activation and deactivation signals it will not activate (as all other actuators). Therefore one deactivation signal can cancel all activation signals.
But this is not the case here. The actuators have one input only. Therefore the visibility gets changed on activation only. According to the logic. They activation is exclusive, either one gets activated or none.
If the key is just pressed the first actuator gets activated -> visibility on.
[TAP] one frame later regardless if still pressed or not the second actuator gets activated -> visibility off.
If it is seen by the audience depends if the frame gets rendered (see post #13).