I have searched the internet for an answer but since I couldn’t find it, I was hoping the unreal community could help me out.
The issue is this: I have three doors that need to slide simultaniously to one side when the player enters a trigger box.
And when the player leaves the trigger box, the doors need to stay at their new position. To this point that part is working.
Now I need help with the part when the player enter the trigger box again, the doors will slide back in reverse to their initial position.
I’ve also attached a screenshot of how the blueprint looks like at present.
(I have two triggerboxes, one for each side of the wall, but maybe that could be simplified?)
basically all you need is a flipflop which will switch its output each time its activated. ill throw together a script in a min to show you how it works.
Edit:
ok ive laid out the script in the picture below. the most important part for you is the last part in the comment box. as you can see here i have the flipflop connected to both the play from start and the reverse from end pins on the timeline. the way this will function is the first time the flipflop is activated it will run the timeline from begining to end as is normal, the next time the flipflop is activated it will use pin B and reverse the timeline from the end basically playing it in reverse which results in the doors going back to the original position. if you activate the flipflop a third time it will go back to pin A.
now to explain the rest. at the beginning you will see a get player character a equal and a branch node, this part makes it so the following script is only run if the overlapping actor is the player. the next part is the do once, sequence, delay, and the custom event, these i used to limit how often the script can be activated so if your player was walking along the boundary the door wouldnt open and close quickly and look glitchy (overlaps can sometimes happen very rapidly and this buffers out some of the activation s). all the sequence node does it to let us run two scripts in parallel, basically run two different things at the same time. and lastly to simplify things a bit i made my 3 doors (cube, staticmesh, staticmesh1) a child of a scene component so that i could move them all together and not have to run multiple timelines or create a more complex script.
as for the trigger boxes i actually used one collision volume for this which covers both sides of the door. i also made this as a actor blueprint and not in the level bp so it can be reused and is easier to make and modify.
thank you so much for the quick reply,you are a hero among humans! Seriously, I am relieved and its mindboggeling to have someone reply on my question with such a great and elaborate answer/ example.
That said, I quickly want to add some more information about the sliding doors in my case; they slide from different starting positions on the x-axis to the same end position on the x-axis. In de screenshot you can see the 4 doors behind the blueprint. Door number 4 on the right will remain on it’s position as it is. But the other 3 will have to move to the position of door 4. Only the first door all the way on the left will have to travel a longer way than the others to reach the position of door 4 on the far rigth, so I don’t really understand how I can make a child of the scene component and slide the doors all together in the timeline. Will that work for sure? Do you by chance know if there is a guide about how to make a child scene component like that? Otherwise I will look it up on the internet.
I also have an “automatic door switch” on the far right on the wall where the triggerbox overlaps to trigger the blueprint.
So how do I make an actor blueprint with all these components in it? I tried to select them all in the content panel, right-click and under the asset actions > create a blueprint using this, but that only works when I have 1 asset selected and not the whole bunch. I can probably move all the other assets into that one blueprint?
And does the get player character node also work with VR?
Please excuse me being a bit inexperienced but I am doing my very best to understand.
i dont know what your talking about with the door switch portion but i can help now with the rest.
ok so with the different movement the portion of making the doors a child of one item doesnt really work and isnt needed anymore so dont worry about it now.
now theres a few ways that we could handle the blueprint now and both arent too hard. the first method ill outline will be similar to the method described before and will be the simplest. the second method will be a bit more involved but will be a little more flexible. first the basics, we are going to make a blueprint actor from scratch in this case so from your main tab with the scene click the green add new button in the content browser, then select blueprint class, and finally actor. now name and open the new blueprint. next we will need to add four static meshes (one for each door), this is done by clicking the add component button in the components section then click static mesh. select each mesh and set its static mesh in the details panel on the right. next position the meshes as they would be in the scene. next add a box collision and have it encompass all the doors (this will be the overlap trigger, added in the same way as the meshes). moving on to the event graph you are going to want to select all the doors and drag them into the event graph then drag off each one and search for get relative location. nex you want to right click the graph and search for make array and plug each relative location pin into the make array as seen below in the picture. next right click the array output pin and select promote to variable. this will create a variable array that contains the doors initial positions.
ok so the next part is like i showed before with the comparing to the player to ensure thats what made the overlap, the do once to limit how often its activated, and the flip flop. actually a good thing to note here is that you could just use the finished pin on the timeline to reset the do once which would make more sense. the timeline is where things start to change a bit, instead of using one float track for the curve i chose to use a vector track instead as seen in picture 3 above. i chose to use a vector mainly because its easier to make changes and looks cleaner. in this timeline x is the door closest to the stationary one (aka door 1), y is the next (door 2), and z is the furthest door (Door 3). so since the doors are evenly spaced we can use the time to keep them all moving at the same pace, so door one takes one second to move to the end location, door 2 takes 2 seconds, door 3 takes 3. i use lerp vector nodes and use the timeline as an alpha so basically the timeline just says it takes x time to move from point A to point B. now we just need to define the start and end locations, luckily we did this already in the array. when using a lerp you need to use static locations otherwise you will get exponential acceleration. so really all we need to do is lerp from the starting location of the door to the location of the stationary door ( array index of the door to index 0), then set the relative location. one last thing to note is the break vector this just lets us get the individual axis from the timeline, note that you can use 3 float tracks in the timeline instead of the vector track and it will all be fine. thats pretty much it for method one just look at the pictures i posted and you should get it.
as for the second method i decided against it for the moment since it would ether not get all doors moving at once or would involve working on tick. however you could also do the method described above in the level blueprint easily as well.
oh also use the reply button when replying to posts and answers as it will keep things neater and more clear. otherwise you are creating answers that arent answers. also over time answers can be reordered based on things like votes so it can get quite confusing.
I’ve done everything as you have explained, but when I hit the play button and enter the box collision space to trigger the sliding door effect, the blueprint halts at the beginning at the branch node (see screenshot of the event).
As far as I know I have done everything exactly as your example piece. But on second thought: could it be the fact that I haven’t put in any value’s at the "lerp vector"node before I plugged in the other nodes? (see screenshot 2)
Also with the “Set Relative Location” node I haven’t put in any values before I plugged in the other nodes (see screenshot 3) and on that screenshot you can also see that I have used the “Get (a Ref)” node for the yellow “Door start locations” node. And I wonder if that was the right choice or not. And that maybe the fault lies there somewhere…
the reason its not functioning seems to be the check at the beginning since you said that it wasnt getting past the branch. a quick fix for this would be to replace the the branch, the equal, and the get player character nodes with a cast to character as show in the picture below. or for the moment you could just bypass all of that section as its only there to prevent other things in the scene from activating the doors (like npcs). as for whether this works in vr i cant say 100% since i havent tested it in vr but it should work fine since you still use a character so its fundamentally the same.
as for your other questions: not having a value on the lerp or any other node won’t matter since you are getting the value from the array. using get a ref for your get nodes should also work just fine thats what i used when testing as well. and finally we used a get player character at the start not a get controller, you used the character in the script as well. the character just gives us something material in the world to work with whereas the controller isnt a physical thing so it couldnt overlap anything, but this is a mute point as we discussed options to modify and bypass this aspect.
the vr character can trigger overlaps right? i dont see why it wouldnt but just asking to be sure.
really appreciate everything you’ve done so far for me to help out!
So I just edited the blueprint by eliminating the whole section you talked about, just to test if the rest would work. And I have made a screenshot of the part where the blueprint is getting red. I really do hope you would per chance know what this could be about. I think that when this part of the blueprint will work as well, the doors will finally get sliding in the scene. alt text