Switching layers on a boolean with dynamically spawned actors
Ok so what I'm trying to do is that I have a boolean and 2 sets of actors. When the boolean is true I want one group to come all the way forward on top of the other and when the boolean is false I want the opposite to happen.
I've checked out tshirtbooth's tutorial on it but the problem is that he edits the actors when they're already on the screen, mine are spawned dynamically.
Is there any way to get them to switch layers like this without editing the one on the screen? I think possibly doing something with spawning a new actor on a higher level and destroying the old one whenever the boolean changes?
I've checked out tshirtbooth's tutorial on it but the problem is that he edits the actors when they're already on the screen, mine are spawned dynamically.
Is there any way to get them to switch layers like this without editing the one on the screen? I think possibly doing something with spawning a new actor on a higher level and destroying the old one whenever the boolean changes?
Best Answer
-
jckmcgraw Posts: 647
@neondevil
Just change attribute self.color.alpha to 0 and back to 1 dependin on whether you want it visible or not.
And GS won't let you switch layers real-time.
Answers
Unfortunately, there is no change attribute: layer right now (hopefully sometime soon). As for the spawning, that sounds like way to much going on at once. What are you trying to accomplish? There might be a much more efficient way of doing it.
Jack McGraw
You just beat me :P
Yeah that's the tutorial I was checking out. I can't actually edit mine when they're on the play field.
@jckmcgraw
Basically you have enemies raining down from the sky, your character is able to switch states to either kill them or be killed by them. I want is so when enemies that can kill you appear they always move to the top of the layers when the player switches states.
Use some attributes for this stuff...
Create a boolean attribute called invincible (or whatever). When you switch states to getting killed or killing them, do this in your code:
In character: when game.invincible = false & overlaps or collides with enemy, run commands...
That way if game.invincible is true, you are free to kill them. This can also apply if you don't want your character to be able to shoot when invincible is false.
Hope this helps,
Jack McGraw
on spawner:
Rule: when
Attribute: game.boolean is true
-SpawnActor and set Layer Order: front of layer
Otherwise:
-SpawnActor and set Layer Order: back of layer
That's pretty much what I'm running a boolean that when a key is pressed swaps the block states.
@Motherhoose
This is what I'm getting at but instead of on the spawn I'd need all the blocks on screen to swap as soon as the boolean is switched.
I don't actually think this was possible but it was worth a shot thanks guys.