What happens if two actors try to change the same variable?
Suppose there's Actor 1, which under certain situations changes the value of an integer Variable1 to 1. Suppose there's also Actor 2, which is in a layer on top of Actor 1's layer, which in certain situations changes the value of Variable2 to -1.
If in between when Actor 1 and Actor 2 are evaluated, the state of the game happens to change so that both Actor 1 and Actor 2 try to set Variable1 in the same pass of the layers, what happens?
I'm having some weird behavior which really doesn't make any sense to me unless it is completely random which actor's variable change goes through. Of course if it is not possible that it is random, then there is something else going on, so I'm wondering how exactly this is handled. I already know that for booleans, any actor setting a variable to true will override all other actors trying to set it to false regardless of their positioning, which is why I'm curious if anything similar happens for integers.
Comments
Layers are read from the bottom up, so the actor highest up will change it last. so if Actor 1 is lower and changes it to 1, then Actor 2 which is higher up will change it back to 0.
Hmm well I kind of assumed that's what should happen. Although that makes understanding this strange behavior very strange...
Would you happen to know why if you change booleans, a true assignment overrides all false assignments even if the false assignments are done by actors which are higher up?
I can't guess why in your case but I can think of reason it might happen, for instance lets say you have a actor low in layers that changes a bool to true and that tells another actor to spawn ?, but another actor above that one would say no don't spawn and changes bool to false but its too late because the spawner was after the true actor and before the false actor. so it spawned and changed back to false.
also
maybe you have bools true and false in the otherwise spot in your rules those can really get you in trouble.
So I would guess something your doing is overriding your rules/logic.
use the Debugger and see whats happening it's very useful.
Remember a code scan happens in .03 of a second.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Just because it's higher in the list doesn't mean it will change it last. It's what ever actor runs the bagpipe last. The list theory only applies if they both hit the same exact change attribute behavior at the same time. The higher one will override.
Hmm I found out why this was happening, although the reason makes it quite harder for me to deal with. Making a new post as the topic is quite different.