How do I set the active instance

0 favourites
  • 3 posts
From the Asset Store
The collection includes pre-categorized selections that can be the definitive tone setting backdrop to gameplay.
  • A newbie question here....

    If a player has multiple units, how do I switch control to another unit? It seems like this should not be too hard, but I am having no luck figuring it out. Using a Boolean instance variable to control which one is active and then trying to select on that with a condition is how I have tried it, but this isn't working. Is there a good tutorial that goes into this in some depth?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • In the properties dialog box is "Default Controls".

    However you decide to switch between controlling player sprites, set the current one to use "default controls" and deactivate the one your switching from..

    Use a global variable (Set_Player). Then make a few statements.

    System > Set_Player = "Player_1" > Player_1 > Stop Ignoring Input

    .........................................................> Player_2 > Start Ignoring Input

    .........................................................> Player_3 > Start Ignoring Input

    System > Set_Player = "Player_2" > Player_1 > Start Ignoring Input

    .........................................................> Player_2 > Stop Ignoring Input

    .........................................................> Player_3 > Start Ignoring Input

    System > Set_Player = "Player_3" > Player_1 > Start Ignoring Input

    .........................................................> Player_2 > Start Ignoring Input

    .........................................................> Player_3 > Stop Ignoring Input

    Depending on the variable value, controls will default to the selected player sprite.

    Hope this helps.

  • I used the system create and destroy actions. Please see the attached example.

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