Physics Interaction: Doors and Locks

Hey everyone,

Physics Interaction: Doors and Locks is a system for adding physics simulation based interactive elements to your project. It is compatible with VR as well.

Marketplace link: https://www.unrealengine.com/marketp…hests-and-more

PhysicsInteraction_DoorsAndLocks284x284.jpg

Preview:

Features:

  • Easy to set up, easy to use, easy to extend
  • Ability to check if Interaction input got used for interacting. Can be used to use same key for both Interacting and any other action (e.g. firing a gun)
  • Supports First person, Third person, Top Down, full VR, and probably any other type
  • Multiple detection methods such as tracing, mouse cursor or custom mesh collision
  • Mesh collision detection prioritizes grabbing Lockset over Openable. Useful for preventing accidentally grabbing door when intended to grab handle in VR
  • Select any actor as a key
  • Basic inventory system for picking up keys (not visual, just a string array)
  • Ability to use custom Collision Profile for Openable and Lockset meshes
  • Basic, modifiable sound system for playing sounds when certain events happen e.g. door opened, lock got unlocked, etc.
  • Save created actors as templates (prefab of multiple actors) to spawn without needing to copy paste/rebuild
  • Easily access events from other actors and extend functionality of system itself

Updates:

Update 3:

  1. Remade template system for 4.24+,
  2. VR input for Demo character is added automatically.

Update 2:

  1. Fixed a compatibility issue with UE4.19,
  2. Made DemoVRCharacter compatible with Oculus Rift.

Update 1:

  1. Added a property to Openable and Lockset for attaching actors. In Static Mesh - Show Advanced > Attached Actors,
  2. Used map same as demo project,
  3. Used Player Controller same as demo project.

Notice: updated Demo after this update was published. In new version of Demo, added a help menu with Controls, 2 quality presets and exit button.

Extra Guides:

Template First Person implementation
This guide will show how to use same Fire input to both interact and fire the gun as default in First Person Template:
[spoiler]

  1. Add Interactor and InteractionModulePhysicsDoorsAndLocks:

Add components

  1. Add a Custom Event node, name it Fire and replace InputAction Fire with it:

Custom Event Fire

  1. Set up event macro as usual:

Event Macro Input

  1. Add a branch and call Fire event node like this:

Event Macro Output branch fire

When you press InputAction Fire it will fire if there are no Openable, Lockset or Key under cursor.

Template VirtualReality implementation
This guide will show how to implement this system with UE4 default VR template:

  1. Add components to BP_Motion Controller, attach Interactor to MotionController component

Add components

  1. Select InteractionModulePhysicsDoorsAndLocks, in Details panel click “Show Advanced” and set Alternative Grab Method to True
  2. In Event Graph after Event BeginPlay add these nodes to use GrabSphere for collision detection just like template’s pick up system

  1. In Event Graph, inside Update animation of Hand comment box, make these additions to play CanGrab animation when this system’s component is overlapped by GrabSphere

  1. Open Grab Actor function from My Blueprint > Functions > Grabbing and make additions as below to use **Interact Pressed **function of our system when there is no pick up actor detected

  1. Open Release Actor function from My Blueprint > Functions > Grabbing and make additions as below to use **Interact Released **function of our system when Openable or a Lockset is grabbed. Otherwise call Drop on picked up actor.

Now, you can both pick up objects and grab Openable or Locksets using same input and animation system of Template VR of UE4.

Horror Engine implementation
To implement this into the free marketplace asset called Horror Engine:

  1. Open blueprint component PhysicsInteraction_DoorsAndLocks -> Blueprint -> Misc -> InteractorComponent, open function TraceCheck and make this addition:
  2. Open blueprint actor HorrorEngine -> HorrorEngine, add Interactor and **InteractionModulePhysicsDoorsAndLocks **components,
  3. Open graph called InputGraph and make this addition:

Known problems/solutions:

  1. When using Undo (Ctrl+Z) after moving/rotating Openable, Locksets attached to it may ignore the Undo and stay where they are.
    Not fixable.
    Workaround: move Openable back manually without using Undo.
  2. Can’t scale Openable and Lockset blueprints.
    Will try to fix in future updates.
  3. After attaching a Static Mesh actor to Openable or Lockset without setting Mobility to Movable, attachment will fail.
    Solution: change Mobility before attaching. If changed Mobility after attaching the Static Mesh, move the Openable/Lockset or change any property to make the Construction Script run.
  4. Attaching an Actor which has a Static Mesh component and the root component isn’t Static Mesh, collision of Static Mesh will block the attached Openable/Lockset.
    Solution: make one of the Static Meshes the root of Actor.
  5. Can’t pick up the key for unlocking a Lockset.
    Solution: make sure the Key actor has a proper collision and Generate Overlap events is set to True for that Collision.

Demo characters in the project are not meant to be used as starting point for your character because PlayerController used for them is very specific to the demo.

Special thanks to Peter Ryan aka TorQue[MoD] for testing, making better models and sounds, and giving some ideas :)​. He is the founder of Apeirogon Games, please check out his site: http://apeirogon-games.com/

First update is live which adds a new feature, changes map and player controller to match the Demo project. Here is changelog:

  1. Added a property to Openable and Lockset for attaching actors. Can found in** Static Mesh** - Show Advanced > Attached Actors,
  2. Made map same as demo project,
  3. Made Player Controller same as demo project.

Notice: updated Demo after this update was published. In new version of Demo, added a help menu with Controls, 2 quality presets and exit button.

Someone else is bound to ask, so I might as well : Multiplayer support?

There is no multiplayer support and we don’t have definite plan for it, however it is not out of question either :slight_smile:

Hi Nicat. I think you forgot to add a locked sound option? My testers are confused weather which doors are usable. Can you add this for an update?

Hi,

From what I understood, you want to play a sound when you interact with a Lockset which requires a key, right? If so, here is how you can achieve that:

  1. In Blueprints folder -> BP_LocksetPhysics -> “Event Graph” - “Extra Events” comment box you’ll find the “Requires Key” event,
  2. Add a “Play Sound at Location” node connected to that event,
  3. Create a new variable, rename it to “Requires Key”, drag and drop it into “Audio” category, change its type to “Sound Base”, make it Editable by clicking the “eye” icon next to it, get and connect that variable to “Sound” input,
  4. Get the “SourceLocation” variable and connect it to “Location” input.

Here is a screenshot:[SPOILER]

Play Requires Key Sound.jpg
[/SPOILER]
This will make it possible to choose a sound to play when a lockset requires a key.

If this isn’t what you said, please send an email with a bit more detail to support address which you can find here (you need to be logged in to see it).

Thanks for suggestion! :slight_smile:

I’m very interested in buying this product
my question is
how is it possible to integrate into the project called
advanced locomotion
you may do a tutorial

Thank you for your interest!

Advanced Locomotion System’s dev has said this:

Also, this is confirmed to work with Advanced Locomotion System v2. So, the setup in the Tutorial PDF should work without any issues.

If you face any problems integrating, please let us know at the support email (you must be logged in to see the email address).

thank you very much
Use advanced locomotion V3
Is it possible that it works?
many things have changed the truth
I would like to see a video that integrates this with a character
I really want to buy
but I would like an extra video
I have seen how it works
has a guide
but a video is missing integrating this
I know that some users who have an advanced character would be interested to see this

Integration is same as PDF or this video. You can add components and input nodes to ALS_BaseCharacter, MannequinCharacter or to your own custom character.

Here is the video of it working with ALS V3 and setup overview:

Hope this answers your questions. Have a nice day!

thank you very much :smiley:

Hi Nicat. Is it possible to send an unlock msg via trigger as opposed to picking up a key? I wanted one bp to send the openable or lockset and unlock msg. Or open message if possible? (have the door open on its own after an event.

Hi, yes you can do both.

Just add these to your trigger BP. Lockset and Openable variables are types of BP_LocksetPhysics and BP_OpenablePhysics. These variables are used to pick the Lockset/Openable you want to unlock/open.

  1. Unlocking Lockset without a key:
    Note: you can ignore the Interact node if you just want to remove the key requirement.

  2. If there are more than one Lockset on a door which you want to unlock. You can just do this instead of the above:

  3. Opening door. This is not supported by default but can be achieved easily:
    Note: change 10 to the velocity you want the door to open at.
    Note2: if door has multiple locksets, connect the Completed node of above setup to this.

Hope this helps! If you need further assistance please use the support email (you must be logged in to see the email address).

Hi Nicat, I am getting errors packaging my game in 4.18.3. I have exclusive Nativized Blueprints enabled. Getting following Error with your BP. Please help. I included an image.

@Architect3D hey, I wanted to let you know that I’m looking into it. I haven’t tried nativization before and looks like there are some problems with my UE4+VS. So it might take a bit before I can determine what the cause is, if at all. It just looks like it is a bit deeper than simple blueprint script issue. However could you check if BPI_HABInteractable is on nativization list? If it isn’t just add it too (by pressing + sign and choosing the BPI_HABInteractable) and if it helps.

It looks like none of the blueprints for this pack were nativized. Unless I turned them off. I think I just turned them off to get it to work.

Could this plugin be used to control a joystick in VR? So like the door handle but on 2 axis instead of 1.

That is a really interesting question :D. At first I thought it wasn’t possible but looks like it is kind of possible but not perfect by any means. I built a demo because I think it is best way to explain why it isn’t perfect. You can download it here: Joystick_OpenableLockset.zip - Google Drive

Few notes: Use left touchpad to move and trigger to grab; Only rotation of hand is used to control “joystick”, location doesn’t matter; I haven’t done any modifications to blueprint to achieve this, except for showing text value. The two meshes are Openable and Lockset blueprints just like door and handle with certain properties; I’ve only tested it on Vive.

I hope this answers your question.

@Nicat The drawers don’t work in VR!!! So a bit more info. When you try to open a drawer in VR it stutters badly and won’t come out all the way. My 1st thought was that I must have gone wrong somewhere setting it up for my character so I took another look at your preview video because I remembered that you showed some VR footage in that but you had skipped the part (in VR) where you opened the drawer so then I downloaded the demo from the marketplace page to see how it is meant to work and it was worse and that was in your project demo so it couldn’t have been something I had done. It barely opened at all. Nicat I can go to the trouble of uploading a video of this issue happening if I have to but I have a feeling you are aware of this issue so my question is, why is this happening and how can I fix it?

Could you add suppot for destructibles? I mean… if a door, closet or a lock gets hit and partially destroyed … having the options to add sound and conditions on the blueprint to slow down the simulation… having the a door or closet moving clunky and so on… Or if you can’t then point to code snippets that need modifications to achieve that. So I would avoid having to study all your code to do that.