fixed turrets

0 favourites
From the Asset Store
10 turrets rendered in 3D with top down and menu views. Three upgrade levels per tower.
  • hi all.

    i added some turret in my game.

    some are working fine.

    but i have one kind of turret i cant code properly

    since my method dont work, maybe someone have an idea.

    these turret goes by group.

    if one turret of "group 1" have line of sight on the player, all turret of "group 1" shoot.

    they shoot straight, dont need to target the player.

    i want add an instance variable called shoottimer, where i can enter the rate of fire of this particular turret.

    some will shoot every 1 sec, some every 0.5, some every 2, etc.

    and i need to tell each turret which rate of fire it will be.

    and when no turret of "group 1" see the player, they all stop firing

    (but turret of "group2" may fire)

    i cant make it work ! someone could help ?

  • your capx would help solve your problem.

  • yep please provide .capx so we can locate the problem. also, which bit of the functionality you listed is not working?

  • ok my capx was very large with many more thing so it would be a bit confusing.

    i made a clean and simple version with only this problem.

    maybe it will help.

    let me know if you have some ideas !

    thanks for your help .

    here is the capx :

    dropbox.com/s/euk17lh5c6scqk6/testsidegun.capx

  • yonda

    capX available

  • set a group for each speed that should work fine

  • Just change timershoot to different values to set the firerate. You've pretty much already done it.

  • yonda

    but it doesnt work. i must miss something in the use of for each.

    all turret fire at the same rate, even if timershoot is different on each turret.

    thats why im asking.

    please, if it seems obvious to you, could you make a capx to show me how it must be done?

  • It is because all of the turrets are clones so when you edit the instance variable it edits it for all turrets. You need to have separate objects really. You can do something tricky with UIDs too but I've not really looked into that.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • jep use seperate turrets. put them into a family.

  • an instance variable allow to have different value for multiple instance of the same object.

    it works for group = 1 or 2

    it works for the life amount and size of different instance of same object.

    i dont know why it doesnt work here.

    i figure another way to do it.

    i will make something like : if timer shoot is 1, turret shoot avery one second

    if timer shoot is 2, turret shoot every 2 second. i think it will work.

    but anyway, i would like to have the solution with "shoot every turret.timershoot" second

    it would help me for many other problems.

  • for those who are interested :

    i did like that, it works fine.

    dropbox.com/s/m4b9v76hvticwxd/sidegun.jpg

    but im still in the 'shoot every turret.timershoot seconds'

    possibility if someone know how to do it.

  • Is group an instance variable? So they are separate objects now then? Because before they were all copies. What's the problem too? I'm not sure I understand from 'shoot every turret.timershoot seconds'. Explain exactly what you want to happen with each group of turrets and when the firerate should change.

  • he has about 9 instances of the tower. he has set an instance variable timershoot. he want that every tower shoots bullets every timershoot time as soon as he walks on the trigger.

  • yonda    exactly.

    i also tried to compare two different instance variable from two different object like :

    if turret.group = controller.group

    but i couldnt make it work.

    so i guess i need to see capx more complicated than what i can do.

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