Bullet Spread Won't Kill Enemy

Get help using Construct 2

Post » Wed Nov 09, 2011 6:51 pm

With my new implementation of spreading bullets, now when you hit an enemy up close (3 bullets contact enemy) the enemy won't die.

This makes no sense.

File
B
14
S
4
G
7
Posts: 17
Reputation: 6,208

Post » Wed Nov 09, 2011 6:56 pm

it worked for me, the problem is that the spread is so wide that it takes the enemy being right up to the gun for all 3 to hit and kill in 2 shots. but its working the way it should on my comp at least.

Edit: maybe a strait 3 round burst per click would work?3DGS2011-11-09 18:58:49
B
15
S
1
G
2
Posts: 62
Reputation: 1,696

Post » Wed Nov 09, 2011 6:57 pm

Works here as well.
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Wed Nov 09, 2011 7:04 pm

The way it should work is the health is 5 for each enemy, so if two close range bullet hits with spread would take away 6, which kills the enemy. But this is not happening.
B
14
S
4
G
7
Posts: 17
Reputation: 6,208

Post » Wed Nov 09, 2011 7:45 pm

Currently its setup so that each bullet takes away 1 from the variable. So u have 3 bullets spreading if only one bullet hits the monster (because the monster is too far away ) then it only takes away 1 health. If the monster is close then all 3 bullets hit the monster and take away 1 each for a total of 3. U need to switch the amount the bullet takes off to 3 if you want it to work the way you say.

Bullet>On collision with monster> Monster spawn explosion
                                  Bullet Destroy
                                  Monster subtract 1 from health

That is the current setup.3DGS2011-11-09 21:06:23
B
15
S
1
G
2
Posts: 62
Reputation: 1,696

Post » Wed Nov 09, 2011 10:48 pm

I've made a video to show my problem, I think it's a bug with Construct 2. Notice the enemy takes several bullet hits (>10) before it dies. Link
B
14
S
4
G
7
Posts: 17
Reputation: 6,208

Post » Wed Nov 09, 2011 11:00 pm

The bug is in the code.
Event13 Instead of monster.health=0 try monster.health<=0 (since if your monster takes 6 shots, its health value is -1, not 0)

Please change the title of your video on youtube.

Your capx with text objects on the monsters to see their health
The fixed version (in event13)
This was to see how each monster behaved.Kyatric2011-11-09 23:04:02
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Wed Nov 09, 2011 11:07 pm

Awesome! Thanks.
B
14
S
4
G
7
Posts: 17
Reputation: 6,208

Post » Thu Nov 10, 2011 1:07 am

When you are dealing with enemy health, you should always set up the death event so that it's like

When EnemyHealth LESS THAN OR EQUAL TO 0

Because the way things work, often you can "overkill" an enemy and nothing will happen to it at -1, -3, or -500 health.

Basically, a lesson you should learn is that when you code in C2 (or anything else) you have to think of ALL the possibilities in your game. In this case, you can't just think "What happens when enemy's health is 0? Easy, death." You have to think "Well what if he's shot a whole bunch of times really fast? What if his health is below 0?"
B
19
S
3
G
2
Posts: 148
Reputation: 1,945


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 2 guests

cron