Is it possible to change an actors "Layer Position"?
Bad wolf Guy
Member Posts: 206
Hello,
It's been 3 years since I last enquired about this, hoping there is now a way. I have 10 actors, all in a row, when touched, I would like it to be on top so when it's moved around it doesn't go underneath the others.
Then if a different one is touch it can do the same thing.
I have tried spawning, but each actor has its own variables it's almost impossible.
Thanks,
Comments
Unfortunately, no. There is no way to change layer order during gameplay.
Mental Donkey Games
Website - Facebook - Twitter
There are plenty of ways, setting up duplicate actors on different layers and controlling their opacity, or controlling their position, or spawning actors either to the top or the bottom of the layer, and so on.
Correct me (again) if i´m wrong, but...
If the actors have self attributes (like they do according to the OP). You can´t really have multiple copies of the actor because the self attributes would not have same values on each copy.
Ofcourse those self attributes can be replaced by tables or game attributes. In that case it would work.
Mental Donkey Games
Website - Facebook - Twitter
I'm not sure I understand what it is you are saying ?
What would cause the attrbutes to change, and why would this be an issue ?
It is a shame and hope it gets considered in future builds (or future engines lol).
I reckon I can make it work with a table and a second actor for everything, involves a bit of work and not really resource friendly but better than nothing.
Thanks @Socks and @NipaDidit
I know you've said you tried spawning, but have you tried specifically:
when touched - destroy then spawn at front of layer?
If all actors are in the same layer, surely this would mean everytime you touch an actor it rises to the top? I bet its not quite what you're looking for so perhaps you could elaborate on your problem... i reckon theres a way to do what you want.
As for variables, why not just have global attributes?
If it just needs to be on top when moving around you could try hiding the actor offscreen or changing visibility and spawning a dummy actor:
So actor names could be 1-10 and within each main actor you could have a rule that says -
When target X does not equal 0 AND
When target Y does not equal 0 AND
Actor name equals (1-10) THEN
Set self position X as target x
Set self position y as target y
Set target X as 0
Set target y as 0
Sorry if that poorly write as I'm on a phone and it hates syntax lol. Hopefully it's not a rubbish idea...
Each Actor has many animations and therefore I can not simple spawn an actor on top because it will mean It will have to know what animation frame it is at, which gets to be too much work. Therefore I decided that, and currently working that I have two sets of each actor. One that is invisible and when touched is changed to be visible. Seems to work alright for now. Just means twice as many actors for everything.
Thanks all,
If you have any rules, behaviours, animations (and so on) in the actor then place them under the rule that switches the alpha to 1.
This is how I have set my layer swapping up, it means that while the actor is invisible none if its rules are triggering. Simply turning the alpha on and off would normally mean all the rules are still triggering on both actors.
@Socks, Not sure if you are suggesting something new or simply have two actors running at the same time.
If I make it that rules and behaviours are only triggered if Alpha = 1 then if the first actor is half way through an animation, the second one that just turned to alpha = 1 would have to start that animation from the start. Again, not sure if that was anything you were explaining. Therefore having two actors always running the exactly same and just changing Alpha in relation to touch would be the way to go.
Have two actors running at the same time, but when their alpha goes to 0 have all the rules and constrains and animations and timers (and whatever you have going on) switch off at the same time.
Only if you set it up that way, you can set animations up however you like.
Except you would be doubling the load on the processor, having the rules only operate when the actor can be seen halves the load and looks identical to the user.
@Bad wolf Guy you can always submit a feature request.
@Bad wolf Guy
Example attached of what I mean . . . . when the mouse button is down we swap layers (using swap alpha values), but the rules - in this example just a cycling animation - stops when you aren't looking at it, depending on how complex your actor's rules are this can save a lot of processor cycles, for example if you have 10 actors like you say, and each actor might have 2 constrains and a timer (or whatever) - then it's the difference between 40 constrains and 20 timers running at the same time . . . or just 20 constrains and 10 timers.
@Socks Right, Makes sense. Wasn't too sure about the animation, but I found away, like you did with constrain image, to have more control over the animation, then actually using the "Animation" behaviour. Should also be easy enough to make it work on more than one of the same actor. I have to laugh how much is involved though. Thanks.