I’ve got everything working except that I’ve no idea how to rotate the door after the button is pressed and the animation is played. Also, there will be multiple doors so I need it to be specific.
You can either use a Timeline with Rotation or you can animate the door, but Timeline is more simple… and to trigger you can use a oncomponenthit or oncomponentbeginoverlap… I hope it helps you…
You need to cast either the BP that have the Timeline in the Widget or the Widget in the BP that have the Timeline… Can you share a print from your Door BP that have the Timeline and the Widget button that you are using? How do you trigger the button in the Widget?
Try to add this:
I created 2 integer variables to work as IDs that will be compared when you click on the Button, and if both match, it will open the door… You probably need to adapt this to your Blueprints, but try this just to understand the idea… I hope it helps you…
Door_BP (were is the Timeline)
(create a custom event with a integer variable and connect to you Door nodes or just a Print String to test)
Widget_BP
(you need to get all actors from your Door_BP… if your door is a unique BP class, you don’t need to create the integer variables in none of the Blueprints, just don’t connect the Array Index, that will communicate with all… the integer variables are useful if you have a Door_Master_BP)
IMO this way you can add more buttons and each run a function of the interface for different sequences (w.g.: Open slow, open norma, kick, etc…). Also doesn’t matter how many doors you add or what class they are as long as they implement the interface.
So it is: Player Interacts → Door → Game Instance → Widget → Game Instance → Door…
If you need to interact only with the closest door to the player there’s a much easier way to do this:
Insert a collision box/sphere/capsule in your door blueprint (if you want to open the door only from one side just put the collision only on the desired size)
Create a custom event called “OpenDoor” that does the opening stuff (I always use “ToggleDoor” and pass a bool to open/close when I create doors, but it’s a personal thing)
OnBeginOverlap cast OtherActor to your player class, on successful cast create a widget to interact with the door, save it to a variable and set self as reference into it (you need to have a door variable in your widget)
OnEndOverlap remove the widget from viewport (the one you saved)
In the widget, when the button is clicked, call the function OpenDoor from the door reference you passed
I just implemented this but thanks for the response! The only problem I have is that for some reason. If you have a door already opened and you try to open another door it plays the timeline for both. I’ve created a variable called: Is open?, where I can check if the door is already open and then only if it’s false the timeline plays but I have no idea what I need to do to make it work.
[edit]
Nevermind, by changing the input to “Play” instead of “Play from start” it works.
I only need to implement that whenever the door is opened the widget doesn’t pop up anymore.