How do I deal with double toggle selections

0 favourites
  • 4 posts
  • I'll try and explain as clearly as I can, I've been running around in circles with this.

    I need to select 1 enemy ship to fire upon.

    Now that ship has to be either

    A) closest to the player

    or

    B) selected by the player selecting him.

    In all cases it needs to be visible.

    My issue comes when selecting a ship that is further away from the closest one that was selected in the code by clicking on him, I can't get it to become unselected, even though I'm making the bool set to false. I need to fix the closest to player statement somehow.

    I'm using 2 booleans on the enemy ship, one is 'selected' and the other 'closest'.

    I'm using the 'closest' bool to select the ship to fire upon.

    Hope that makes sense!

    thanks in advance

    Here's what I have but it's not working.

  • Is enemyshield in a container with Enemy ?

    If not, Enemy is unreferenced (not picked) in event 425. So all Enemy get marked as picked.

    Same for PlayerSelect, if there are more of them. In 428.

    If they are in a container, it could work. Difficult to debug with a screenshot.

    I would use containers, for sure. Then (i think, from my head, so untested). Combine in one event.

    Conditions:

    Enemy = visible ?

    Pick nearest enemy to player position

    Actions

    Set enemy instance variable 'CanBePicked' to true

    To pick with the mouse

    Condtions

    EnemyShield clicked by mouse (must be in a container with the enemy)

    Enemy 'CanBePicked' is true

    Actions

    Enemy set picked

    And ....

    Condtion

    Enemy is picked

    Action

    set playerselect (if there is only one) to postion of enemy (or shield, i have no idea where you want it)

    set playerselect visible

    Else

    set playerselect invisible

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I think 426 is setting picked to false on the newly select enemy instead of the previous one? The first 3 events probably need some kind of rework. I also don't think 425 and 426 should be checking at exactly the same time, from the logic anyway.

  • I reworked a bit of the code but I fixed it with a 'OR' statement for my weapons.

    Enemy is Picked
    or
    Enemy is closest[/code:cnm3v7ap]
    This way if there's a picked enemy it doesn't take into account one that is closest, and if there is no picked enemy it uses the closest one.
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)