Instance variable destroys two not one

Just started using Construct 2? Post your questions here

Post » Wed Jan 07, 2015 5:26 pm

Hi,
I have been trying to make a game and along the process I have encountered a bug. Its when an enemy's health (instance variable) < or = to 0 Enemy Destroy than, add 5 to score. The code is in the attachment below.
You do not have the required permissions to view the files attached to this post.
B
18
S
3
G
4
Posts: 63
Reputation: 2,795

Post » Wed Jan 07, 2015 7:40 pm

This is the wrong section BTW. You should really post this in the 'How Do I' section.
Have you used debug to see what value(s) health is holding? It may not be a whole number, due to the way computers calculate numbers, so using one of the usual expressions may help, such as round, Int etc.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
136
S
31
G
86
Posts: 5,487
Reputation: 59,760

Post » Wed Jan 07, 2015 10:58 pm

@zenox98 I will remember that topics like this are supposed to go in the 'How Do I' section. Health holds 10 health than it goes down to five than zero and than bot instances are destroyed. It remains a whole number no matter how the player hits the enemy. What do you mean
usual expressions may help, such as round, Int etc.
B
18
S
3
G
4
Posts: 63
Reputation: 2,795

Post » Thu Jan 08, 2015 9:41 am

What about the events that damage the enemy? Maybe you damage both enemies when you hit one. The event you showed would only destroy two enemies if they both have health <= 0.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,670

Post » Thu Jan 08, 2015 1:17 pm

@r2cvv There's nothing wrong with the piece of code you've shown... I'd guess the error is somewhere else in the code. Care to share the capx?
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
20
S
6
G
3
Posts: 624
Reputation: 3,750

Post » Thu Jan 08, 2015 1:19 pm

ramones wrote:What about the events that damage the enemy? Maybe you damage both enemies when you hit one. The event you showed would only destroy two enemies if they both have health <= 0.

@ramones Here is the code for the player attacks. Whether it is the first code or the second they will both be destroyed.
You do not have the required permissions to view the files attached to this post.
B
18
S
3
G
4
Posts: 63
Reputation: 2,795

Post » Thu Jan 08, 2015 1:26 pm

@brunopalermo @Ashley I have followed some of ashley's tutorial on how to make an enemy move back & forth.
B
18
S
3
G
4
Posts: 63
Reputation: 2,795

Post » Thu Jan 08, 2015 1:29 pm

Still you need either to replicate the issue in a new capx if you don't want to publish the current capx, or just go and post your capx so we can investigate it further.
There is nothing wrong with the few lines of code you've shown so far and we can't guess how you made your project.

If you fear people stealing your project, don't fear.
It's not working as intended at the moment anyway, so there's nothing to steal.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
294
S
117
G
96
Posts: 7,310
Reputation: 71,084

Post » Thu Jan 08, 2015 1:30 pm

@Kyatric I'll PM you the capx.
B
18
S
3
G
4
Posts: 63
Reputation: 2,795

Post » Thu Jan 08, 2015 1:40 pm

Just share it here and we all might help... Seriously, nobody is going to steal other people's projects around here... And ideas are overrated anyway.
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
20
S
6
G
3
Posts: 624
Reputation: 3,750

Next

Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 3 guests