3
$\begingroup$

When I pull out a weapon (weapon-switch), a prop ("Timer_Activate") is set to 10, the number of frames for the weapon-switch animation. If you swap weapons, it will set the prop to 20, and the prop will drop every tick by 1 till it reaches 0. Once the prop is at 0, you can fire. The problem is, if you swap between a weapon, and you hold the fire-button, you will fire 1 bullet before the prop turns into 20. This happens all the time and can be a cheat to gain fast-firing weapons. How can I fix this "lag"? Any help is appreciated. Thanks!

Use my .blend to see the issue firsthand:
Press 1 or 2 for any of the 2 weapons, and make sure you are holding down left-click as you are swapping, you will fire 1 bullet, then the animation plays and the timer is set to 20.

If you cannot download the .blend or can't find the issue, be sure to check out a gif of the problem here. (The gif is slightly modified but you can still see the issue.):

$\endgroup$
  • $\begingroup$ Wouldn't it suffice to set it to 46...? $\endgroup$ – someonewithpc Jun 19 '15 at 15:06
  • $\begingroup$ @someonewithpc I agree that it should be closed as either unclear, or too localized; however even mods can not close a question with an open bounty. $\endgroup$ – David Jun 19 '15 at 15:32
  • $\begingroup$ It would help if you posted your code or .blend, without which we don't have much hope of debugging the problem.. $\endgroup$ – gandalf3 Jun 19 '15 at 18:45
  • $\begingroup$ @gandalf3 I am using logic bricks, so I don't have any code. I heard that logic bricks sometimes need 1 tick to do an action. This might be the problem. Is this true? $\endgroup$ – blackhole Jun 19 '15 at 20:01
  • 4
    $\begingroup$ @blackhole We want to be able to help you, but this becomes difficult when you don't cooperate with us. It's okay if you don't want to share a .blend you put lots of your own time into (thats completely understandable), but if that's the issue you can just say so. Restating the problem in bold isn't going to help anyone. Take a moment to look your question from the point of view of someone ready to donate their time to debug and answer it. Would you want to spend your time on this question? Or would you rather answer a question which is asked respectfully and includes extra info you ask for? $\endgroup$ – gandalf3 Jun 20 '15 at 1:23
7
+50
$\begingroup$

Problem

The problem was that, your integer property Timer was still equal to 45 when the weapon was switched, for exactly one logic tick, allowing a shot to escape. Then, one tick later, the message actuator could deliver the message to assign the property Timer to 0.

Reason

The message system actually takes one logic tick from the time the actuator receives the positive pulse from the controller, to the time when the message sensor on the receiving end receives the message and sends the positive pulse to it's controller(s).

How to fix it

I have un-checked the the check boxes on all of the logic we aren't using so it will be easier to see the necessary change. (re-check them before testing)

enter image description here

Your end result should look like this, only without the actuators on Active_Determiner

Essentially, all you need to do is Delete the logic bricks marked by a red box, and connect the bricks where the Blue lines are.

This will completely cut out the message system, (and the one-tick delay) and directly connect the bricks instead. enter image description here

result:

It works! - yay!

enter image description here

If you didn't understand that, don't feel bad (logic can be confusing.) here is the blend file in case you did get confused.

| improve this answer | |
$\endgroup$
  • $\begingroup$ I knew this was the issue! Thanks for the answer, but I have my weapons and armatures in another scene. Should I just move the determiner object to the other scene? $\endgroup$ – blackhole Jun 20 '15 at 19:54
  • $\begingroup$ Yes, that would be the best way to do it. (and make it by far easier.) $\endgroup$ – X-27 wants to Reinstate Monica Jun 21 '15 at 0:30
  • $\begingroup$ That strategy would cost me days to accomplish considering that I have tons of objects that rely on copying properties from it. This would be difficult. Can I use python or any other way to fix this? $\endgroup$ – blackhole Jun 21 '15 at 0:52
  • $\begingroup$ to quote from the documentation, the python controller is essentially an infinity customizable logic brick so obviously it is possible, (But I have no idea how.) Have you considered trying to duplicate the determiner object to the other scene and have the same events that trigger it to change, make both of them change? $\endgroup$ – X-27 wants to Reinstate Monica Jun 21 '15 at 1:49
  • $\begingroup$ "Have you considered trying to duplicate the determiner object to the other scene and have the same events that trigger it to change, make both of them change?" I am confused. What do you mean? $\endgroup$ – blackhole Jun 21 '15 at 4:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.