Shooting problem

0 favourites
  • 12 posts
From the Asset Store
Shoot balls to destroy as many blocks as possible, at each stage the game will become more difficult.
  • 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 ;)

    <img src="http://img801.imageshack.us/img801/5875/68ci.png" border="0" />

    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)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You can try adding a straight line across the entire row and use these:

    • When [Line] is overlapping [Enemy]

    -> every X second(s): cannon shoot

  • 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 :)

  • 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.

  • 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 :)

  • 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.

  • 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 :)

    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.

  • 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!

  • 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

    dropbox.com/s/lpie0pw3gkddalz/MyTry.capx

    I will be really gratefully...

  • 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

  • nimos100

    ouu thanks man this is really awesome and I think it solved my problem completly

    I will try to understand it whole :) and remaked it to my game thank you once more

  • final result of fire system:

    ubru.g6.cz

    I am reworking my game from construct classic so do not care about menu or some numbers just pres "menu" for go on...

    thank you nimos100 :) great solution with these trackers (invisible)

    PS: you can build, destroy, cooldown is on etc...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)