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
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:
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:
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
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.
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
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:
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.
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.
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.
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!
Correct 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.