nzhu's Recent Forum Activity

  • I am writing a turret defense game. To spawn turrets, I click on a turret icon, which also just happens to be a stationary copy of the turret.

    Everything aside, the problem is with the Create Object function.

    When I click on my Turret Icon, I create a turret at Mouse coordinates and it is attached to my mouse. Problem is, the origional turret Object also flies to the mouse coordinate!!! No where in my code do I tell the original object to go to my mouse coordinate. The origional turret object/icon is just supposed to act as an icon to create an identical copy of it.

    But this problem where the origional turret goes to my mouse ONLY occurs with the origional turret. None of the created copies of the turret have this problem.

  • Hi again,

    I've been making a complex turret defense game for the past 3 weeks and I'm currently at 500 events.

    The last and [I think] final problem i am faced with is that the enemy paths can get blocked. Then when the enemy gets blocked, no more enemies get summoned, and as a result the game essentially crashes.

    Before a turret is built, I want to verify that the path isn't blocked but I'm not exactly sure how to do that.

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

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

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

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

  • O wow it worked!!!

    Thanks so much!

    I had no clue what Tokenat meant until now. Thanks!

  • > But, I want the peer's changes to be transferred to the host as well so that the "sync" is both ways rather than one.

    >

    The plugin doesn't work that way, the host should always be authoritative over changes. In your case when you want the peer to summon an object, what you can do is to have the peer to [action: send message] to the host, then at host, on peer message, you spawn the object on peer behalf. That way the object will be automatically sync over all peers.

    Thanks for your Reply. After thinking about what you've said, Here's my new logic:

    1. Peer creates object.

    2. The object's created coordinates are stored in two global variables, objectX, and object Y.

    3. Then send two messages to the host each containing the global variables, objectX and objectY

    4. Then I want to sync the sent messages to the same global variables, except on the Host's side.

    5. Then from the host side, I can do action, create object at the locations of the global variables.

    I want to do the above, but I'm having trouble at step 4, figuring out how to set my Host's global variables to the sent messages of the Peer's equivalent global variables, objectX and objectY.

  • Hi, so I am making an online multiplayer game and both players can summon objects.

    So, I use Multiplayer Sync (and it's implied that there's a host and a peer).

    The problem is that the sync only works from the host to peer only.

    But, I want the peer's changes to be transferred to the host as well so that the "sync" is both ways rather than one.

    Is there a way I could do that?

    Thanks for helping!

  • Got it thanks so much!

    Now I'm going to try to add multiplayer features with a Lobby and everything for an online 1 vs 1 turret defense game.

    But....I'm looking at rexrainbow's smaple code andd wow it looks diffiicult!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi thanks so much for responding,

    Yes after testing each possible variable, after like 5 hours I figured out that the enemies were moving to the conditions set at the start of the map regardless of what solids were moved/spawned around afterwards

    I was looking for could reset this "initial condition" but I couldn't find it.

    Thanks for telling me.

    My next problem is that I don't have "Regenerate obstacle map" as an action.

    What I do is:

    I click on action -> look at Layers&Layouts-> *But I don't see regenerate obstable map anywhere.

  • actually to be more specific,

    The enemy ONLY goes through Spawned versions of the turret, but the origional turret behaves correctly (it treats it like a solid and avoids it).

    Why is it that it is only going through the spawned turrets? I thought the spawned turrets inheret the properties of the origional.

nzhu's avatar

nzhu

Member since 6 Nov, 2014

None one is following nzhu yet!

Trophy Case

  • 10-Year Club
  • Email Verified

Progress

11/44
How to earn trophies