How do I switch between two different characters?

0 favourites
  • 7 posts
From the Asset Store
Adjusting the game screen for different resolutions (Letterbox scale)
  • I don't know how to switch between two different characters pressing a key (I mean, I want to be able to switch between them pressing the space bar while im playing) its possible to do it?

    No se como cambiar entre dos personajes presionando una tecla (quiero decir, quiero poder cambiar entre ellos presionando la barra espaciadora mientras estoy jugando) es posible hacer eso?

  • I don't know how to switch between two different characters pressing a key (I mean, I want to be able to switch between them pressing the space bar while im playing) its possible to do it?

    You need to use instance variables, because there is no condition to see if the platform or 8direction behavior is enabled.

    You have to set the instance-variables on the start in a state that make sense (one characters has to be the controls enabled the other not). Then you have only to change the instance variables and the conditions.

    I made a little example.

    https://drive.google.com/uc?export=down ... XdLTE1XZWM

  • thank you for reply, I tried to apply what you did in my own project but I got "Else (not valid here)" I don't know what to do about it

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Be sure that that the else follows direct after the previous event and not as a subevent. It doesn't work with triggered conditions (the one with the green arrow).

    Run if the previous event did not run. Note that this condition does not pick any objects: if it follows an event that picks objects, in the Else event all instances revert to picked again. Else can only follow normal (non-triggered) events. It can also follow another Else event with other conditions to make an "if - else if - else" chain.

    https://www.scirra.com/manual/124/system-conditions

  • I will try it and see what happens, but I have a doubt, when I press a key (the X) If I'm using the sprite 1 while I'm playing, I dont want the sprite 2 to be in the game and viceversa, what you're teaching me works like that? or both sprites will be in the screen?

  • I dont want the sprite 2 to be in the game and viceversa, what you're teaching me works like that? or both sprites will be in the screen?

    There are both sprite at the same time on the screen in my example. There are several possibilities to have only one sprite at the time on the screen. You can put one sprite outside the layout, make it invisible or destroy it and create a new one every time you switch. I't depends what you want to achieve.

    If it is regardless which position the sprites are after switching make them invisible. If you want to switch positions of the sprites set Sprite1 on position of sprite2 and then sprite2 outside of the layout and vice versa.

  • i managed how to switch between them but pressing A for one of them and B for the other, i have a fox and a wolf, the fox is supposed to be faster than the wolf, now I have a problem, when I switch between them they dont appear in the same place where the other was at first, one of them almost always appears more far than the other (because the fox is faster), Im sorry for the late reply, Im very sick

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