How do I set the active instance

Get help using Construct 2

Post » Wed Jan 28, 2015 2:58 am

:? 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?
B
3
Posts: 1
Reputation: 177

Post » Wed Jan 28, 2015 3:17 am

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.
Image
B
75
S
23
G
3
Posts: 673
Reputation: 9,283

Post » Wed Jan 28, 2015 3:34 am

I used the system create and destroy actions. Please see the attached example.
You do not have the required permissions to view the files attached to this post.
B
5
Posts: 23
Reputation: 317


Return to How do I....?

Who is online

Users browsing this forum: Armench, brunopalermo, dand, TRMG and 25 guests