How to switch between actors?
Alano
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
Hi Alan,
Sure, assuming you have both the little guy and giant actors built you would just do this on each actor:
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
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
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:
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
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
....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
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
Watch my gamesalad logic series. It takes time to learn and understanding how logic code works is vital.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Wow, so my 12yr old son got it to work!
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