How do I Count bullet shot

Get help using Construct 2

Post » Sun Nov 16, 2014 8:34 am

Hi. In the game you have to hit a target. When 3 bullets were shot and no target were hit the game will restart. The problem is i added global variable that counts bullet shots, but when you shot the third bullet it automatically restart the game without waiting if the target was hit. Hope you understand the question.

my eng sucks lol
B
11
S
3
G
1
Posts: 418
Reputation: 1,780

Post » Sun Nov 16, 2014 9:05 am

Use the "On Destroyed" condition on the bullet. Add 1 to the global variable when a bullet is destroyed. And when a bullet hits a target, reset the global variable to 0.

Make sure you destroy the bullets when they hit a target, wall, or are outside of the layout.
B
72
S
27
G
17
Posts: 254
Reputation: 14,971

Post » Sun Nov 16, 2014 9:14 am

yeah , to be more specific, the bullets are actually Arrows that got pinned to wall if u missed a shot, So it not going to be destroyed, Any other idea?
B
11
S
3
G
1
Posts: 418
Reputation: 1,780

Post » Sun Nov 16, 2014 9:19 am

Use the same mechanic, when arrow collides with wall, add 1 to global variable. Instead of adding 1 when you shoot it.
B
72
S
27
G
17
Posts: 254
Reputation: 14,971

Post » Sun Nov 16, 2014 9:29 am

That sounds like solution really, but what if the player shots in the air, the arrow got destroyed after leave the layout and it will no longer work ,
Last edited by ex32 on Sun Nov 16, 2014 9:29 am, edited 1 time in total.
B
11
S
3
G
1
Posts: 418
Reputation: 1,780

Post » Sun Nov 16, 2014 9:29 am

.............
You do not have the required permissions to view the files attached to this post.
Image
B
63
S
23
G
7
Posts: 1,480
Reputation: 10,796

Post » Sun Nov 16, 2014 9:33 am

Korbaach as always best answer. :-)
but thank you xavier for your time taken. Appreciated really
B
11
S
3
G
1
Posts: 418
Reputation: 1,780

Post » Sun Nov 16, 2014 6:05 pm

uff i am back here. Everything worked perfectly , until the second level of my game , where the arrow bounce from solids, so it has multiple collisions in 1 shot. It bounce from wall and floor and the counter no longer work :-/
B
11
S
3
G
1
Posts: 418
Reputation: 1,780

Post » Sun Nov 16, 2014 7:01 pm

Add an instance variable that tracks if it has ever hit. If not, set it and count it, else don't.
ImageImageImage
B
71
S
21
G
220
Posts: 3,648
Reputation: 123,725


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests