How do I switch from player 1 to player 2

0 favourites
  • 8 posts
From the Asset Store
Players follower. use it for anything which follows the player
  • Hi,

    Recently downloaded the demo of constructor and love it, I've learned a lot but so far I can't switch from on player to another.

    I've looked at all the youtube videos and tutorials but they all add in extra things which I don't need.

    Could any one tell me how to have two sprites on screen (player 1 and player 2) and when I click another sprite (change player) the next player is then active. When I press change player again it goes back to player 1.

    Any help would be really great.

    Mark

  • You enable/disable the platform or 8-direction behaviour (however they move). Assuming they are two different objects, have an instance variable on the change player button that goes between 1 and 2 when clicked or something similar. When the button shows 1, then enable movement on player 1, disable on player 2, when the button shows 2, then disable movement on player 1, enable on player 2.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you so much for your reply, I understand what you say and it makes sense.

    But

    I've added an instance variable on the changer player button, I set number to 1

    The picture below works and stop both of them moving (I've not added anything to stop them both moving at the start)

    but when I click change player again, nothing happens.

    I know I've done something wrong, sorry to be a pain.

  • We don't hate people that need help with C2 lol. You need a condition that blocks the other one out. All actions run at once when it is true and from top to bottom in C2. You need to put in a condition on the left, something like on clicked if changeplayer is 0, set changeplayer to 1. And on event 3 you need if changeplayer is 1 set changeplayer to 0. However, because they run top to bottom in C2, you're going to find that it looks like nothing is happening because event 1 is true then event 3 is true. Usually for this i add a wait of 0.1secs on the actions on the right hand side.

  • Thank you once again, believe it or not I really do try to learn things myself without having to ask people.

    I think I've done what you suggested and only the first player moves, when I click change player, the first still moves.

    Thank you so much.

  • You could also use a global variable that switches between Players depending on what it is set on

  • Hi,

    Thank you, I got it working in the end, I needed to put every tick.

    I'll paste it below in case someone else finds this post one day. Thank you once again for your help.

  • I think a more efficient way to do that would be to give both players the "scroll to" behavior and turn it on and off like you do with 8Direction. The advantage there is that you can add "Trigger once" to the conditions for Changeplayer=0 or Changeplayer=1, and the event won't have to run every tick. The difference is meaningless for a small game, but it can become important to avoid triggering events more often than necessary if performance becomes an issue.

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