How do I create a unit that shoots 1 projectile?

Get help using Construct 2

Post » Fri Oct 17, 2014 3:28 pm

Hi everyone,

I looked around hours and days but I don't know if I do wrong or if Construct 2 has a bug.

I have several units of the same instance that spawn and need to shoot one projectile once an enemy reaches their range.
When they do so, some units (not all) will shoot more than 1 projectile.

This is really annoying because it breaks all balancing tweaks.

Do you have any idea of what I am doing wrong?
Here is a short Capx I made to focus on my issue.

Thank you for your help. I don't know how to fix this?
You do not have the required permissions to view the files attached to this post.
B
26
S
10
G
3
Posts: 72
Reputation: 4,008

Post » Fri Oct 17, 2014 4:43 pm

Removed all the "For each"'s and the problem disapeared. "For each" isnt necesary for what you are doing.
B
10
S
4
Posts: 133
Reputation: 1,543

Post » Fri Oct 17, 2014 6:15 pm

Duh!
Thank you lmchucho
it works well indeed without "For each"
I will become crazy, I don't know why when I tried at home without the event "For each" it only works for one unit.

Now, it is working perfectly without it :)

Thank you for your time :)
Cheers
B
26
S
10
G
3
Posts: 72
Reputation: 4,008

Post » Fri Oct 17, 2014 10:25 pm

@lmchucho
Actually, it does not work for my mechanic.
I need to keep "For Each" because I can have bigger enemies that overlap other enemies. Therefore, I use a variable that correspond to their Y position.
Like that, my characters can shoot the correct enemy because they are on the same Y.

I tried to remove for each and now, my characters shoot but their projectile pass through the enemy. Which is normal because they do not match their Y position anymore.

If I remove the variable for the Y position, the projectile will hit the enemy that is not on the same line but can overlap the Y position.

Anyway, I really believe that there is a bug because it does not make sense why "For Each" will impact the Spawning Event even if I put a Trigger Once.
B
26
S
10
G
3
Posts: 72
Reputation: 4,008

Post » Fri Oct 17, 2014 11:24 pm

@UNDERDOG

I am not a computer where I can look at your CAPX but let me give this a shot.

Add an instance variable to your enemy called Bullets - make that 1.

Add an event- on enemy spawn bullet - subtract from enemy instance variable 1.

Another Event - enemy spawn bullet if instance variable is equal to or greater than 1.
(PLUS whatever other actions you have to spawn bullets such as in line of sight or whatever)

See if that works. Again I am doing this without looking at your CAPX so I have no idea if that is relevant.
B
13
S
5
G
1
Posts: 119
Reputation: 2,292

Post » Sat Oct 18, 2014 5:12 am

Hey Robertjs3,

nice idea Robertjs3
In the capx, I did not use this approach.
I used a boolean for the same purpose but on my main capx and it did not work neither.
However, I will investigate because I may use it at the wrong place. Thank you, I will double check my events, you may point something I do wrong :)
I'll keep you posted guys,
B
26
S
10
G
3
Posts: 72
Reputation: 4,008

Post » Sat Oct 18, 2014 5:24 am

@Robertjs3

It works with a variable that I set to 0 before it spawns the projectile and once the animation is finished, I set it back to 1.

Thanks again guys!
B
26
S
10
G
3
Posts: 72
Reputation: 4,008


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 29 guests