How to switch between actors?

AlanoAlano Member, PRO Posts: 70

Hey all,

My son is making a game where the heroes are a giant and a little guy. Each will be needed for different tasks. Is it possible to switch between these actors within the same level? Like button A for one and button B for the other?

THanks!
Alan

Comments

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    edited May 2014

    Hi Alan,

    Sure, assuming you have both the little guy and giant actors built you would just do this on each actor:

    When button A is pressed:
    Spawn big guy
    Destroy little guy
    
    When button B is pressed:
    Spawn little guy
    Destroy big guy
    
  • AlanoAlano Member, PRO Posts: 70

    Thanks Jamie,

    Ahh, but is there a way to do this without killing the other actor. Can both actors be in the same scene? For example, Both enter a room and the giant stays at the back of the room while the little guy fights bad dudes. At the far end of the room is the cave to the next level but it's blocked by fallen rocks. Tap (or press a button) on the giant standing at the back of the scene in order to activate him to come over and break through the wall. Is this possible?

    Thanks!
    Alan

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    Sure that would be possible too. I'd probably use a Boolean Attribute, when it's True 'turn off' the big guy and 'turn on' the little guy and when its False 'turn on' the big guy and 'turn off' the little guy. (that kind of sounds wrong... lol).

    Buy turn on and turn off I mean switch control too and from each actor. You'll need to come up with the correct behaviors for how your game is put together but that would be the general idea, like this:

    Rule: When mainActor is true
    Do the little guy stuff...
    Otherwise (mainActor would be false)
    Do the big guy stuff...
    
  • AlanoAlano Member, PRO Posts: 70

    Okay, so here is what I have:
    1.Game Boolean attribute (MainActor)
    2.In both actors:
    -----When touch is pressed=Change Attribute game.MainActor To: True. [below this I have my move commands], Otherwise:Change Attribute game.MainActor To: False.

    I have this rule in both actors and my thought was that if I touch the Giant he can then move and the little guy becomes False and the little guy can't move. Likewise, if I touch the little guy it locks up the giant. But, of course this does not work. When I preview the little guys for a few minutes then stops. The giant never moves.

    Am I close on this rule?

    Thanks!
    Alan

  • AlanoAlano Member, PRO Posts: 70

    ....oops. When I preview the little guys right and left BUT my cursor is off screen. As soon as my cursor comes on the the screen the little stops moving.

    -Alan

  • AlanoAlano Member, PRO Posts: 70

    Okay, I'm still having much luck with this. Advice anyone? Is it easier with two buttons:
    Button A controls the giant.
    Buttons B controls the little guy.
    I understand the overall idea of making the unchosen on "False" and the flipping to "True" when selected. I just don't understand the details on how to get there.

    Thanks for you help!
    Alan

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    Watch my gamesalad logic series. It takes time to learn and understanding how logic code works is vital.

  • AlanoAlano Member, PRO Posts: 70

    Wow, so my 12yr old son got it to work!

    • He made 2 REAL Attributes (Giant, Small guy)
    • In Giant actor= Rule:Attribute, when game.Giant = 0, move (he did the usual R&L move)
    • Same for Small actor except he used "game.Small=0"
    • He made "A" "B" buttons for each actor.
    • Button "A"= Rule: when touch is released, change attribute Giant=0, change attribute Small=1. Otherwise: change attribute Small=0.
    • Button "B" is the as above but swapped actors.

    This totally works! So press "A" and the giant moves, small guy doesn't. Press "B" the reverse works too!

    Now, Anyone have an easy way to jump? I searched the forum and tried the simple suggestion of press button "C" and change velocity Y but it didn't work. Is it because there are two actors? I did put the jump behavior in both actors. No luck.

    Thanks in advance again!
    Alan

Sign In or Register to comment.