Bug? Maybe I'm doing something wrong..? HELP!

0 favourites
  • 5 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Edit: I've uploaded a cut down sample game to the new post below. It should explain things in more detail.

    Cheers

    Chris

    ---

    Hi guys

    I've been trying to debug a game for a few hours now and I can't quite understand why something isn't working. I've looked through the forum but because I'm not sure what's going wrong I can't really find anything similar.

    Basically, on the start of the layout I create 9 characters (In family 'AllCharacters') and set their associated ChracterID variable to their UID.

    Then I create a random weapon (From the 'Weapons' family) for each of them and set their CharacterID variable to the same as their linked character's CharacterID variable.

    The 'Weapons' family has a variable called 'Type' which indicates if it's a "Melee" or "Ranged" weapon.

    I'm trying to pick all the 'Melee' weapons and their associated character like so:

    [attachment=1:2fkz14pr][/attachment:2fkz14pr]

    When I run this it seems like the correct number of weapons are being picked however their linked character (based on CharacterID) is not being picked correctly.

    If ALL weapons on screen are assigned 'Melee' then it works fine and their associated character is picked 100% of the time. However as soon as one of those weapons are no longer 'Melee' weapons it tends to break and not pick the correct number of characters:

    [attachment=0:2fkz14pr][/attachment:2fkz14pr]

    I've debugged the game above where there is one 'Ranged' weapon and all characters and weapons have the correct CharacterID and Type assigned.

    For the purposes of this test, I was hoping to be able to set all their opacities to 70%.

    I'm obviously not understanding how Construct 2 picking works, so would value some insight into why this might be ocurring.

    Thanks!

    Chris

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Really struggling here - any thoughts or assistance would be very much appreciated.

    Cheers

    Chris

  • I've attached a sample game where you can get an idea of what's going on. Press 'A' to create 4 sprites (Let's call them 'Characters') in the centre of the screen, each with a small sprite on top of them (We'll call them 'Weapons').

    Each set of Character+Weapon has a unique identifier for them starting at 1 and going to 4.

    Pressing 'S' will delete all 'Blue' weapons as well as their linked (via 'ID') character.

    Or it SHOULD at least... What it does seems to be rather random.

    I'm not sure if it's a bug or if I'm just not doing something correctly... Please help, I've been stuck on this for months!

  • Think this is what you are after Zacros

    [attachment=0:13mr2g7j][/attachment:13mr2g7j]

  • Thanks mate, really appreciate your help!

    While it most certainly helps for this instance, I don't think I can use the same logic with other scenarios.

    For instance, let's say that the Character family has a variable called "HitPoints" and I'd like to destroy only one of the characters (randomly) that have HitPoints of 0 and a Blue weapon.

    If I add in a pick random, it deletes them all, as it's still going through a loop for the weapons.

    To put it in another scenario, I'd like to be able to keep weapon variables on the weapon and character variables on the character. Then I'd like to be able to do "Every 5 seconds, pick one character that has HitPoints > 0 and a linked Weapon that is blue, then move that character 10 pixels to the left. If I use the attached method, it'll move all of the characters that fit the profile, not just a random one.

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