Physics Based Door Blueprint does not act Independently when multiple are placed in scene

I have a Blueprint for a door which acts much like doors do in the Amnesia games. My issue however, is that I want to place multiple instances of this door blueprint throughout my level but whenever I open one door, they all open.

I also can’t help but feel that there is a more efficient way of going about my code, please let me know of any suggestions that you may have.

Code Logic from My First Person Blueprint
So, my doors opening/closing code is first powered by a line trace (when Left Click is Pressed) from the first Person Character Blueprint to see if it touches a Door or the Physics Door Asset Class

When door is being grabbed, the camera freezes, this is the logic for freezing the camera:

Code Logic from my Physics Door Blueprint
This Blueprint also starts with the left mouse button being pressed and is initiated with the following code

This pic below is what is what happens after I cast to my First Person Blueprint. This code is how I Turn the door open:

The viewport for my door is as follows:


I have a hinge Physics Constrain which ensure that it can only rotate left and right

Sadly, I cannot currently upload Videos since I am new, but any help that can be provided would Wonderful as I’m still learning UE5.

Thank you everyone in advance for any help you may have!

i cant see everything there so ill give you a few pointers.

  1. you wants to use Interfaces (plenty of tutorials on youtube)
  2. you want the door logic on the door, you can use a timeline rather than tick
  3. dont use GetActorOfClass

simple flow

player presses button
line trace for actor
call interface function on actor
actor function opens door

2 Likes

As above but also here’s the entire setup with interfaced doors:

2 Likes

Hello @Everynone and @Auran131! Thank you for responding to my post so quickly! So I’ve been fiddling around implementing the code and suggestions that you both have provided, but have one hiccup with my implementation.

For my Blueprint, I have Physics Handle-related logic which also relies on my Left Mouse Input. My action Mapping has two triggers; Pressed and Released:

(I can only have one pic per response so I will have to have quite a few responses :roll_eyes:

My issue, is that the blueprint example that @Everynone provided has an Input mapping that is constantly firing when the left mouse input is entered.

Comparatively, my code is only firing once every time I press/release the Left Mouse Button which means it is only rotating the door for one single frame. This problem still exists even when I use the Triggered output on my Action Mapping.

I have tried removing the Triggers on my side which ends up fixing the issue with the doors, but breaks my Physics Handle logic. Still, I am unable to show videos of what is happening now since I am a new user to the forums but will have some of my code’s logic here:

To Start, I initialize my logic for picking up objects or opening Doors here:

How would you like Input to trigger? Once (when pressed / released) or every frame? Triggered fires every frame, for example.


Physics Handle

Instead of Adding Force, you want to use Physics Handle on the constrained component - is this the ideal scenario? Not sure if that’s the right combo - both components will attempt to constrain the target at the same time. Might be fine, though.

It would be preferred if I could have a pressed/released kind of system as it would align with the Physics Handle code I already have for the Left Mouse button.

When it comes to adding force, I am only adding force when throwing objects that I have with my physics handle

1 Like

Just to clarify, how is it supposed to work in game:

  • we approach the door
  • press the LMB once and doors fully open?
  • or, we grab it with the Physics Handle and manipulate it for as long as the LMB is down? ← judging by the released on cancel.

Well, I have an older version of this door where there is no Physics Handle component involved. It is disabled when a door is hit by the line trace and the player simply Adds rotation to the door based on the player’s left/right mouse input.

This is the way I would like it to work :slight_smile:

So we hold the LMB / RMB down and the door opens closes? No need for a physics handle then, not for the door.

Or, do you have to use it (for whatever reason)?!

So, in short, you want to use input Started / Completed (because other systems require it) but the door should open in a physical fashion.

Only the left mouse button being Pressed/Released will control the door. You are correct about the physics handle, there should be no Physics handle involved here haha.

Here is what I was talking about when it comes to the logic that I had for my old door system, I want it to work similar to this (but without those awful casts that I have everywhere lol):

When you say open in a physical fashion you are referring to the doors physics being simulated correct? Because I would like the doors physics to be simulated whilst being opened/closed or idle.

But yes, it has to be this way since my Physics Handle code needs to be kept this way and is also mapped to the left mouse button

1 Like

I’d do it like so then:

  • the LMB goes down, we send an Interface Message:

  • the door interprets it like so:

  • optionally, Instead of gating Tick, you could Enable / Disable Tick
  • another option is to increase motor’s target orientation - but this could get fussy / clumsy

You’d use the same script for the RMB but the bool will be reversed:

image

The result of using just LMB / RMB:

Does this look about right-ish?

  • holding LMB keeps pushing the door
  • holding RMB keeps pulling the door
  • letting go LMB / RMB lets the door be

Obviously, you’d need to work in direction for the other side of the door, as in the original post.


those awful casts

Do note the interface shines here. You can send the same Interact2 message to any other actor and its job would be to interpret the message for themselves.

2 Likes

This is somewhat how I would like it to work. Preferably, the Left mouse button should be responsible for both opening and closing the door and the Right Mouse button should not be used at all for doors (I apologize If I made things confusing earlier, I’m only using the right mouse button to throw objects that have been grabbed by the physics handle logic I have later in my code and has nothing to do with the door)

The Left mouse button should be able to manipulate the rotation of the door by getting the value of the Mouse’s X Direction.

For example:
If the door is selected (By the line trace) after the left mouse button is held down, it should be able to rotate to the left/right based on the value of the mouse moving to the left and to the right. When the left mouse button is released, then the player should have no control over the door.

Thank you! :slight_smile:

But this is precisely how my original script works - in the linked thread. It must be updated every frame (triggered) becase we need to sample mouse axis.

That is correct. The dilemma that I’m running into is that I would like to use the original script’s code, but It does not work due to the way I have my Input mapping configured with the Pressed/Released Triggers.

I guess what my question is, is do you know any way that I can keep my Pressed/Released Input for interacting with the door? I would like to use the method you have for your script where there are no triggers but it would break the current logic I have for my Physics Handle.

Thanks again for everything!

Ah Ha!!! After messing about with the code, I now have a solution that works. I used a gate so that I could use the Triggered Execution Pin to be used when connecting to the Door Interface.

I wish that I could show a video to showcase that the script now works but I’m still apparently a “New user”.

But thank you soo much @Everynone! I see why you have the Community Hero Status, I’m not sure I would’ve been able to come this far without your assistance!

In good regards,

POTATOGAMER :slight_smile:

Correct :+1:t2: I have since been able to remove the triggers associated with my input mapping for the left mouse button so that the triggered pin will fire continuously. Originally in my script this was not the case.

Now the script is working as intended :grin:

1 Like