Waiting for weapon reload.. using wait not working

Get help using Construct 2

Post » Sat Jan 18, 2014 5:24 pm

On LMB I do a sword slash, on RMB I allow the weapon to be "fired". I want a time penalty for firing the weapon which is "WeaponRespawn".

Here's a code snippet:


Problem: First time it works, second time it does not, third it does, fourth it does not, etc.

On debug I can see "WeaponLaunched" is being set to 0 right away on each 2nd shot. Can't see how this would happen.

silkc22014-01-18 17:26:59
B
20
S
6
G
2
Posts: 157
Reputation: 3,111

Post » Sat Jan 18, 2014 6:41 pm

Try getting rid of the "else" event
B
87
S
44
G
16
Posts: 1,005
Reputation: 17,938

Post » Sun Jan 19, 2014 2:21 am

Don't put it in a sub event, just put it right under the wait statement in the same event. See if that works.ArcadEd2014-01-19 02:22:16
B
101
S
32
G
11
Posts: 1,546
Reputation: 21,667

Post » Sun Jan 26, 2014 11:28 am

[QUOTE=justifun] Try getting rid of the "else" event[/QUOTE]

Then I can fire / slash infinite times at once.. I only want the wep on screen once at any one time and the Else.. delivers that logic.
B
20
S
6
G
2
Posts: 157
Reputation: 3,111

Post » Sun Jan 26, 2014 11:28 am

[QUOTE=ArcadEd] Don't put it in a sub event, just put it right under the wait statement in the same event. See if that works.[/QUOTE]

Have tried, same issue..
B
20
S
6
G
2
Posts: 157
Reputation: 3,111

Post » Sun Jan 26, 2014 12:31 pm

Try using a timer instead of wait.
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,882

Post » Sun Jan 26, 2014 12:40 pm

Something like this ?

simple timer for bullet delay
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,882

Post » Sun Jan 26, 2014 1:50 pm

I've also found that Wait and Timer triggers sometimes fail to fire even though the logic of the events looks good. I've also had them stop working for no reason after I've been working on a different part of an event sheet, but nothing consistent enough to put in a bug report for proper analysis (only enough for me to occasionally moan about it! ).

My advice would be to do 2 things here:

1. Add a tripple event containing (1)Sword is on screen Inverted - AND - (2)Swordbull... is on screen Inverted - AND - (3)Trigger Once. Use this to set a variable "player_can_fight_time" to "time + Player.WeaponRespawn".

2. Check player_can_fight_time < time as a pre-event to your key down checks (in place of the WeaponLaunched = 0 check). That should do it.

Good luck! Like I said before, I've often found that once a game becomes very complicated with lots of time checks and trigger checks, the triggers sometimes get missed. This has resulted in an enemy not shooting at the player, for example (which can just about be excused) or something like the above problem where the player can no longer interact with the game (= fail!). This time check using an object variable technique might seem to be a pain at first but I've never found it to let me down (I rarely use Wait and don't use the Timer any more and I don't have to solve problems like this either...).
A big fan of JavaScript.
B
74
S
20
G
71
Posts: 2,230
Reputation: 44,892

Post » Sun Jan 26, 2014 2:11 pm

[QUOTE=RamPackWobble] Something like this ?

simple timer for bullet delay[/QUOTE]

Timer did the trick, thanks. :)
B
20
S
6
G
2
Posts: 157
Reputation: 3,111


Return to How do I....?

Who is online

Users browsing this forum: panku, TRMG and 35 guests