How do I Upgrade My Turrets

0 favourites
  • 8 posts
From the Asset Store
10 turrets rendered in 3D with top down and menu views. Three upgrade levels per tower.
  • Hey guys thanks for your help over the past few weeks.

    It's been 3 Weeks I discovered Construct 2, and I've done things I wouldn't even think possible in such a short time.

    So, 400 events laters I am stuck again.

    I've been making a rather complex turret defense game and other details aside, I am stuck on upgrading turrets.

    I want:

    1. Each instance of a turret to be upgraded individually on mouse click

    My Thought process:

    I want so that on click of a turret instance, an "upgrade" button becomes visible. Clicking on this button, the turret instance variable, "TurretLevel" is incremented by 1. Then, the projectile sprite instance variable, TurretPower is calculated as TurretPower= (TurretLevel+1)^2. Then when projectile overlaps my enemy sprites, TurretPower is subtracted from EnemyLifePoints. When EnemyLifePoints is lessthan or equal to 0, it is destroyed.

    My problem:

    I can't find a feature that lets me obtain the identity of a single turret instance just be clicking on it.

    It's easy to upgrade all turrets at once using pick all, and I can't specify the exact instance because it doesn't mean it's the right one.

  • HI nzhu I needed to solve this for myself recently. I created an instance variable and set an identifier for each instance.

  • In order to pick a single instance is Construct2 you need to reference it in the conditions portion of an event.

    If you use on-mouse-click instance type the specific instance you click on will be "selected", you would then have your event continue on to modify the instance variables of the selected instance via sub-conditions/actions attached to the same On-click condition... of course each instance will have to have all the necessary instance variables

  • HI nzhu I needed to solve this for myself recently. I created an instance variable and set an identifier for each instance.

    Ohh Nice idea!

    So If I understand you correctly, you essentially mean this,

    1. Create object

    2. When object is created, for example add 1 to an instance variable, Identifier

    3. Choose event, "On left mouse click on Turret" && "Identifier = 1" (or 2,3,4 depending on the number of turrets made)

    4. Add an action, Add 1 to Instance variable TurretLevel

    5. Now, only the selected turret witch matching Indentifier will have the level of the turret upgraded.

    I haven't tried it yet, but that's my new logic.

    Does it seem reasonable?

  • In order to pick a single instance is Construct2 you need to reference it in the conditions portion of an event.

    If you use on-mouse-click instance type the specific instance you click on will be "selected", you would then have your event continue on to modify the instance variables of the selected instance via sub-conditions/actions attached to the same On-click condition... of course each instance will have to have all the necessary instance variables

    Thanks for reponding.

    Yes that is what I am trying to do.

    I am confused on how to reference the specific instance that is being clicked on.

    I don't think I can't use a specific instance (like Pick nth Instance) = 0 or 1 or 2 etc since turrets will be spread all over the map and so I can't just pick any single one without any way to identify that specific instance.....

  • It was a little different for my application but it looks like you're along the right lines.

    In fact, in your instance you might want to use 2 instance variables, one to identify the specific turret and the other as a record of the upgrade level for each turret.

  • It was a little different for my application but it looks like you're along the right lines.

    In fact, in your instance you might want to use 2 instance variables, one to identify the specific turret and the other as a record of the upgrade level for each turret.

    Cool.

    Now, I just realized a problem.

    The identifier is a set part of the event condition.

    That means that I'll need to make as many events as there are identifiers.

    What if someone made 100 turrets? That means I'll have to make 100 events. One event for each instance.

    For example:

    Event 1:On left mouse click on Turret" && "Identifier = 1

    Event 2: On left mouse click on Turret" && "Identifier = 2

    Event 3: On left mouse click on Turret" && "Identifier = 3

    .

    .

    .

    Event 100: On left mouse click on Turret" && "Identifier = 100

    Is there an easier way to consolidate the 100 turret instaces = 100 events into a few events?

    And I have 12 different turret types, 6 for player 1 and 6 for player 2....sooo if I do it this way, I'll end up with like 1200 events.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could do a "For each" loop on the object, check for mouse click and then use the variable in your action.

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