Doors open after shooting the target.

Hello,
I’m currently working at my very 1st UE5 project. I used the First Person template, then created my whole “level”, but now I have a problem with doors. When creating them, I was basing on this video: How To Create A Door (Blueprint) - Unreal Engine 5 Tutorial - YouTube

Because I didn’t want to close the doors, I didn’t make it exactly how the video presents, but even though, they still work. My blueprint for them looks like that:

I placed more than only 1 on my level, so I also created a variable “ID” for them and I set different ID for all doors at my level. Now there’s where my problem begins… I don’t want them to open when player is close, but only when the target that is in other place (not on the door) was shot, or when multiple targets were shot at least once.

After some research I tried to make it like it was described here: Shooting a button to open a door?. I created “Custom Event” and renamed it “OpenDoor”, but unfortunately, I don’t understand the next step, “then in your level create a box trigger and also drag in the door bp”.
I opened my Door Blueprint, but how am I supposed to drag the box trigger there? I just placed it on my level by using option “Quickly add to this project”, but I can’t just drag it to Door Blueprint Event graph. It’s just impossible (or i’m doing something wrong?). I also can’t

Right now my Door Blueprint and Level blueprint are looking like that:

Doors

Level

Can anyone help me with this? I would really appreciate that.

Hey @NexUs. Made this quick demo to try and make it work how you want. It’s a bit different than the linked tutorial but think it could be of more help.

This is how it works:
DoorMultiLocks


The trigger actor
  • Only component with collision is the Box, it’s set to Block All.
    image
  • Create a function to invert a bool and call a dispatcher:

    The bool is set to false by default. Running this will set it to true and the dispatcher is so that any actor listening knows it was changed.
  • Since you are shooting the actor you can run the function on AnyDamage event:
The Door actor
  • Create an array of reference to the lock actor:
    image
    Be sure to enable InstanceEditable so that the locks can be manually selected in editor.
  • Create a function to bind the dispatcher of the actors added to the lock array:

    On the create event node select Create Matching Function. This will generate a new function.
  • On the generated function we loop the actors to check for their bool:

    The branch will stop the loop on a false and the execute the open/close door custom event passing the last value of the loop.
  • Finally the open / close door as you have it but now with the input variable to know if it should open or close:

Here are some references that will help you study some concepts used here:

Hope it helps.

2 Likes

Hi @pezzott1,
thank you very much for help. I tried to do everything as you described and I understood the overall idea. However, I still have a problem, because it still isn’t working at all.

I wanted trigger to be small, round and without any glowing parts, so instead making it as a box, I made it small, round and black. Then I made the Toggle State function, but since I don’t need the trigger to glow, I didn’t create the Set Glow Color function. After that, I entered the Event Graph tab and created that Event AnyDamage thing.

As for the door I created the Array in the way you told me to and then I created also the Bind Lock Triggered function. Atfter that, in the Create Event field I selected “Create Matching Function” and it created a function that I renamed to “Locks Check”. At the end, in Event Graph I made everything like you showed on your screenshoot.

When all things mentioned above were done, I placed the door and the trigger on the wall next to it. I also renamed that trigger to “StartDoorTrigger”. After that, I left clicked on door and added 1 element to the array. When the “Index [0]” thing appeared I changed its value to the “StartDoorTrigger”. It looks like that:

That’s all I did and for me it looks almost exactly like how you described and showed on your screenshots (the only difference is the lack of Set Glow Color function and the names for Door and Trigger actors), but for some reason when I did it, it’s not working.
I was trying to upload here more screenshoots, but since I’m a new user here, I can’t upload more than only 1.

I was trying to find the problem for the entire day and still got almost nothing… :frowning:
Do you have any ideas what could I made wrong or what should I check?

Ok. The events should execute in this order: Trigger recieves damage | dispatcher fires | door recieves the call of the dispatcher and executes the binded function | finally execute the custom event. So all we have to do is place print nodes at the start of each to know what is executing and when.

Lets try and follow the chain to see what is not working. Add a print at the start of each so we can visually track what happens when the trigger gets hit. The result should look something like this:
image

Start at he trigger:


A bit redundant but still add one in the function:

Then in the door add one at the binded function:

And finally at the custom event:

We can determin the problem faster by looking at the last printed text.

You can also use breakpoints for this. Print nodes will work just fine if you are not familiar with them.

Let me know how it goes.

1 Like

Ok, I did as you told me to and something strange happened. For some reason none of those texts showed up. I guess that could mean that I’ve messed something up right at the beginning, when I was creating the trigger actor? Or maybe I should’ve changed something also in the Projectile Blueprint?

That’s how my Trigger Actor looks like right now:

To be sure if it’s not a problem with my viewport window that texts doesn’t show up, I also added one text to appear right after I start the game and it worked.

My guess is that the projectile is not applying damage to the trigger.

Can you show the projectile blueprint?

1 Like

When creating project I used the First Person Template. The projectile blueprint was already there and I didn’t change anything in it:

Add this node to the projectile:

BaseDamage has to be greater than 0.0 and select DamageType from the dropdown list for the class.

1 Like

Ok, it worked. Now the doors are opening and closing properly.

Thank you very much for your help.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.