Hi,
I am having an issue with using the flip flop node on multiple actors of the same class. Basically, I have an actor that I have setup to move along the x axis or y axis when touched and dragged. I made it to where it checks for a boolean and based on the boolean, allow the player to move the actor on one axis at a time. I then made a flip flop connection to toggle between the two axis. This works perfectly when there is one actor in the scene. However, If there is more than one actor, only the last actor added to the scene will communicate with the flip flop. I tried to use a get all actors node and that didn’t work. Also, without the flip flop, I am able to have multiple actors in the scene move on different axis with no problem. So I have narrowed it down to the flip flop node being the issue.
Do I have to do something special to get it to communicate with all actors of the same class in the scene?
i doesnt sound like a flipflop issue to me it sounds more like a reference or input issue. you seem to have a lot going on in your explanation which complicates things a bit, some screenshots may help so we can see how youve set things up.
one of the big questions i have is are you trying to make all the actors move at once or only one of the actors. also you mention “checks for a boolean”, where is that bool? in the player character? in the actor?
lets say you have the bool in the player character and your trying to move all actors. a simple way to do that would be to use the get all of class to get references to the actors in the level, then use a for each loop to affect each one (ie move them).
I was using an old content example from unreal and just added to that. The content example is this one Mouse Interface | Unreal Engine Documentation
I followed that and the added some things to it:
I added two booleans to the actor that I am touching. One boolean for the X axis and one for the Y axis. I then did a check once the object is touched to see which axis is active. I did this for each event that was added in the Content Example. By default X is true and Y is false.
I then did one more boolean check before it sets the actors new location. This one is to let the actor know whether it should move along the X or Y axis.
I have the flip flop setup inside the same actor, right now just attached to the R key for testing.
Oh and no I will only be moving one actor at a time. Only the one that is touched.
for the R key, theres a few issues id say. the first question to consider is when R is pressed who should receive that input? all actors or just one (if one how do you specify)? ok so if you want R to affect all actors then you need to ensure that the input isnt consumed. to do this you just need to select the R input event node and in the details panel uncheck consume input. if consume input is checked then the newest actor (last placed) will use the input since you have input enabled on all actors and the input is then consumed so other actors cant use it. if you want R to only affect a certain actor then you will need to only enable input to the actor you want to be affecting. try it out and let me know how it works out it may solve your issue overall.
overall i think you could simplify the script shown in picture 2. in your setup currently when X is active Y is inactive and vice versa. so you really only need one bool variable such as isXActive? if true move on x if false move on Y. you could then take that a step farther and use a select node to eliminate the redundancy of your script.
below is a example of the script. a few notes: i made it in a character since thats a class i had handy, you would put yours where you have it. i also used a different input again it was handy sub as needed. also theres a probably a more elegant solution for the making of the vector but this is just to show how you could reduce the redundancy.
Having to press twice i would say is because your setting the bool to the state they are already in on the first press. That would make all the actors the same bool state wise which negates the per instance changes you made. If you want to have the actors bools be set on a per instance basis then you wont want to use a flipflop, instead you will need a script which checks the current state then sets the bool to the opposite. Its pretty simple get your bool then plug it into a branch node, if branch is true set bool variable to false, if false set variable to true.
Ok great I can do that. Thank you for the help!
Thank you for the answer and the tip. I definitely thought I was redundant in the script. I did turn off the consume input and that allowed it to affect all actors, perfect. But now there is a new problem that might be related to the redundancy. The reason I had two booleans was because I wanted to make them instance editable so that I could set some actors to start on the X axis and some start on the Y axis. Then when the button is pressed, they switch. The problem is that any of the actors I start on the Y axis require the button to be pressed twice before they begin switching axis. Would this possibly be because of how im checking the booleans?
I thought of another way to accomplish the bool switching. Get the bool var then use the not operator then set the variable to the nota output. That should work