address specific unit and variables (?)

This forum is currently in read-only mode.
From the Asset Store
SCI-FI Units SFX contains 456 sounds With this pack, you can voice almost all the units in your sci-fi strategy game
  • hello folks

    hmm i don't know how to start..

    for an rts game:

    i want to have a unit selected, check weather it has the pv "can_build" set to 1 and if so draw a "build_button" on the navbar at the bottom.

    i was somehow thinking that i can set a global variable "selected_unit" set to the unit you selected or the first one if you selected multiple units. then just do something like:

    if (selected_unit.can_build == 1)

    build_button.visible=1

    else

    build_button.visible=0

    does this somehow work in construct?

    it's annoying when you know how to do something, but don't know how to tell construct to do it ^^

    it may have something to do with getUniqueID but i can't search for that because the words are to common.

    this is how i would do it in WorldEdit (warcraft3 editor) where "unit" is a variable type.

    so i am basically asking how to address a specific unit (and its variables...), i guess...

    thanks

  • It's unecessary to try and work out how to store a "reference" to an object in events. The usual way is just to use the object-picking conditions to run the logic. For example, given the situation:

    • each 'unit' has the private variables is_selected, can_build
    • 'build' button should be invisible unless a selected object (is_selected = 1) can build (can_build = 1)

    Then you can just take advantage of the top-to-bottom execution of events:

    + Always

    -> Build button: Make invisible

    + Unit: 'is_selected' equals 1 (...picks all selected units)

    + Unit: 'can_build' equals 1 (...picks all selected units that can build)

    -> Build button: Make visible (...this only runs if at least one object met the above conditions)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • so simple and it makes sense.

    thanks so much

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