Shooting problem

Get help using Construct 2

Post » Sat Jul 06, 2013 8:59 pm

Hello I need to solve my shooting system and maybe little more understand how C2 works. I looked on forum read something but I still do not understand it.

For example: you have got 3 horizontal lanes you can build a defend towers (on left) to these lines and towers can shoot on enemies. Enemies are random spawned at the lines (on right) and run to towers (from right to left).
I need to make:
- shooting condition for these towers (if enemy and tower in same line has same Y position than shoot)
- shooting speed (I would like to make it as variable of these towers)
- stop shooting if there is no enemy in same line as tower

screen help to understand what I mean... similar to Plants versus Zombies game ;)


I think I need to create independent timer for every instance of tower and independent picking of instances if tower instance has same Y position as some enemy than tower start shooting when enemy die tower stops...

I really need to solve it thank you very much for some solution and example (sorry for my low english)
B
11
S
3
Posts: 37
Reputation: 999

Post » Sat Jul 06, 2013 9:48 pm

You can try adding a straight line across the entire row and use these:

- When [Line] is overlapping [Enemy]
-> every X second(s): cannon shootaznmonkeyboy2013-07-06 21:48:48
B
8
S
2
Posts: 40
Reputation: 2,136

Post » Sat Jul 06, 2013 9:58 pm

If your using the turret behavior then you can add certain targets to each turret,
on start of layout - 'tower1' add turret target 'enemy1'
and you can set bullet speed, rate of fire, predictive aim etc,
it will be more precise but aznmonkeyboy answer is the easiest :)GeneratorX2013-07-06 22:00:06
B
4
S
1
Posts: 51
Reputation: 502

Post » Sat Jul 06, 2013 10:33 pm

I already tried that thing with some line and overlapping like condition... and also that turret and it did not work as I want(maybe I make something not correctly)...

I think there are some other problems that I need to solve... I mean "every second" is global time not time of one unigue instance of tower so with "every second" command all towers release shoot (bullet) in same time...
I want tower that can shoot independent of other towers (all towers are same object only different instance).

Maybe I miss something thank you for some advice.Ubru2013-07-06 22:56:16
B
11
S
3
Posts: 37
Reputation: 999

Post » Sun Jul 07, 2013 12:00 am

Try to add some variables. Make it so every turret has its own timer variable and make them shoot at random speeds. Or you could just modify rate of fire of each turret. And you could just provide CAPX file that would be great :)
B
17
S
3
Posts: 26
Reputation: 1,518

Post » Sun Jul 07, 2013 12:10 am

You can add timer behaviour to the tower object, that will allow you to control them individually.

If you do that, its a good idea, I think, when you apply tag. Just to make a tag like this "Reloading" & tower.UID, that way you know what the timer is doing when scrolling through you program, but also it makes them easy to select as each timer is unique for each tower.

B
44
S
11
G
2
Posts: 1,181
Reputation: 6,816

Post » Sun Jul 07, 2013 2:32 am

[QUOTE=GeneratorX] If your using the turret behavior then you can add certain targets to each turret,
on start of layout - 'tower1' add turret target 'enemy1'
and you can set bullet speed, rate of fire, predictive aim etc,
it will be more precise but aznmonkeyboy answer is the easiest :)[/QUOTE]

The turret behaviour is good for a lot of the tower defense games you see that use a radial targetting system. Ubru asked if there was a way to make it akin to Plants vs Zombies.
The problem with the Turret behaviour here is that the turrets will start target enemies on other lanes.

@Ubru
I actually forgot one more step Ubru. Apologies.
Like L3mon said, you can differentiate them using variables.

1. Give both your 'towers' and the 'lines' an integer variable respective to their lanes. ( say for example {lineNum} )
2. If an enemy is overlapping said 'line', you can then compare and pick the 'towers' who's {lineNum} matches up with the 'lines' {lineNum}
3. then FIRE AWAY.

I'll see if I can whip up an example for ya.
B
8
S
2
Posts: 40
Reputation: 2,136

Post » Sun Jul 07, 2013 2:55 am

Here you go!
https://www.dropbox.com/s/mle77558kxcymws/LineDefense.capx

edit: Oh lord! There were so many problems with the .capx, I hope no one's seen it. It's fixed now though. I hope this helps!aznmonkeyboy2013-07-07 03:10:29
B
8
S
2
Posts: 40
Reputation: 2,136

Post » Sun Jul 07, 2013 8:33 am

thank you all very much... that example has good shooting condition...

but I still do not know how to fix that shooting delay and start to shoot independent on other towers (problem with "every 1 second" in condition block)

@nimos100
your idea is good but how can I do it?

please someone try to rework that .capx (or my simple clone below)
UPDATED
https://www.dropbox.com/s/lpie0pw3gkddalz/MyTry.capx
I will be really gratefully...Ubru2013-07-07 11:58:16
B
11
S
3
Posts: 37
Reputation: 999

Post » Sun Jul 07, 2013 11:49 am

You link doesn't work.

Anyway here is an example of how to do it.

It uses a tracker for each tower, that will trigger the tower when an enemy is within range. And will cause that tower to shoot. As it would in a game like Plants vs Zombies.

Tower test
B
44
S
11
G
2
Posts: 1,181
Reputation: 6,816

Next

Return to How do I....?

Who is online

Users browsing this forum: FabianB, Vodakman and 9 guests