How do I create a locally updateable variable
So, what's really bugging me is that you're unable to overwrite variables in a local space. I have an object with some logic, and I want to copy the object several times, with each having it's own variables. When using the variable modifier, I'd have to rename all the modifiers and variables for each individual copy. While this is an option, I'd guess there is a way to do this locally.
In my case, I am creating a multiplayer game. I want to give a value to a box where players can step on. When they step on it, the value of the box changes.
For example:
No player has stepped on the box - Value = 0
Player 1 has stepped on the box - Value = 1
Player 2 has stepped on the box - Value = 2
Player 1 steps on the box again - Value = 1
I have all the logic in place, except for this bit. It is important the value stays the same when the player leaves the box, so it will only update once another player steps on the box again.
-
Essentially you're looking for dynamic text fields, and I haven't seen any evidence of this. For example you can't use a wire into a Text Display containing the text you want it to display, nor can you perform operations on fields like concatenation e.g. "Box"&{SpawnNum}. You'd use this to name (and find) tags/variables which is what would solve your problem.
A hacky workaround might be to use a selector instead, that looks for collision with each PlayerPossession state. Then have a generic tag for your outputs (NoPlayer, Player1,Player2) and use a Scene-sized Zone to count how many of those tags exist (I'm sure there's an output in there for that). Then you can wire that to a single variable in your world logic, and now you have each cube managing its state by itself and the game tracking how many of each are in each state. -
Hi there, I'm guessing you are labelling the players and then detecting those labels and using a variable modifier to set the value of the variable associated with the box?
And the issue is that you want to rename multiple boxes to have different variables?
I don't think there's a way to rename those clones automagically, it would have to be done by hand.
If it's local though, perhaps you don't need a variable and could just use a counter since your variable is a number?
That way each box would have it's own counter and it's own value and each player just sets whichever counter they step on to their associated value -
I don't have the game in front of me now, but I'll try to explain what I think could work for you.
First, do you actually need it to be a variable? Can it just be a number in a value slider?
If it can be in the value slider, you could do this:
Set a trigger zone on the box and leave it on detect possessed.
Wire the output to a Splitter, connect the plus symbol output to the A input if 2 AND Gates.
Wire the 1 output of the splitter to the B input of one of those and gates.
Wire the 2 output to the B input of the other.
Wire each And gate output to separate Value Sliders' power.
Set the first slider to 1, the second to 2. (You can turn off the setting to see the slider itself)
Connect both of those sliders to a Signal Manipulator
With the tweak open, home L1and X on the input to set it to blend.
Wire the signal output to a final Value Slider.
Wire the Plus output from the Splitter earlier, to the Signal Manipulator's Freeze output option.
Now when player 1steps in the value is 1.
Player 2 will set it to 2. And the value should hold until someone else us detected.
Please sign in to leave a comment.