Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Opening a door with the headsets controllers.

A topic by will.anstey created Oct 14, 2022 Views: 62
Viewing posts 1 to 1
Developer (5 edits)

Beginning this week I want to finish the door completely, starting with this goal I decided to deconstruct the solution to help me to learn as much about Unreal during my process.

During the process of deciding what kind of door to create, I considered my 3 choices, an automatic door that detects when the player is near and opens, an interactive door that when interacted with (triggered) opens on an axis, or a door that the player can push to open.

I started by developing the automatic door, the tutorial showed process for this option was simple enough, using a collider on the actor to trigger when the player gets near and using the matinee editor and making the rotation of the door stored in the actor.  I assumed that applying this rotation would be easy as it is just an actor being affected by another actor and therefore can just be done using the level blueprint. I first searched for an OnEnterTrigger node and realised that was a part of Unity's toolset. After a quick search, I found the OnActorBeginOverlap and hooked it up to the play node which was directed toward the matinee actor. I checked using the actor to make sure that the door would open and then I checked the document tutorial to make sure 

Beginning the development of the second option I wanted to try to create the door by myself, this development was done a few weeks after the first and also after I'd made the first iteration of the button and therefore I had a wider knowledge base than a few weeks prior. I began by duplicating the last door but removing the trigger box and the blueprint editor code that went with it. Once I had the door base I used the knowledge of how to interact and move an object I had just learned from making the button, I added the cube collider to the door with means that I could push it using the VR hand controllers. This is where I began having problems in development. I'd forgotten how to use the matinee editor and spent some time looking through my notes realising that I should spend a large amount of time developing my base skills

Unreal API writing Team. 2021. Setting Up a Door. https://docs.unrealengine.com/4.27/en-US/AnimatingObjects/Matinee/HowTo/MHT_1/

Using a static mesh of a door from the asset set I'm using for the house and texture changing function I had the door model with its pivot changed to the edge of the door so that it can rotate properly.  Starting by adding a physics constant inside a blueprint, then I added a small cube next to the static mesh as the tutorial I was watching uses another object to rotate the door itself around its axis. Adding the static mesh and cube to the constraints of the physics constraint was the first step as this allows them to move with each other, then we set the angular limit as I am setting up a swing and not a linear movement. Next, lock swing 2 and twist and set swing 1 to limited. Finally, I enabled simulate physics. At this point I had a door, a grabbable and pushable door, however, I wasn’t happy with how it functioned. It felt to me like the player had to get far too close to the door to interact with it. Additionally, my idea for each feature took inspiration from a game called Due Process, in this scenario walking up to a door and just pushing it wouldn’t be ideal so I planned to design a door that the player could walk up to, press a button and if the player was in range the door would open.

The tutorial used: Sir Fransi. (2020, April 27). How to make VR door and opening it (unreal engine VR tutorial)[Video] https://www.youtube.com/watch?v=_HULVPAOj6Y&ab_channel=SirFansi

Unfortunately, it was at this stage where my source control error took its effect and I lost all work after finishing the automatic door and was back to square one with the grabbable door. However, this wasn’t particularly bad for me as I decided I didn’t like the pushable door anyway so I set out to create an automatic door that opened when the player pressed something.

Using the previous knowledge I research event overlap nodes in order to find one to attach the sphere to detect when the player enters said sphere, I found the On Component Begin Overlap and its counterpart the On Component End Overlap node.

Unreal API writing Team. 2020. On Component Begin Overlap. https://docs.unrealengine.com/4.26/en-US/BlueprintAPI/Collision/OnComponentBeginOverlap/

This node would allow me to trigger the door opening whenever the sphere overlapped but also trigger the door closing whenever the overlap ended.

Next, I wanted an elegant solution to replace the use of the matinee editor, I had previously made the lever feature so was planning on using the SetRelativeRotation node as I had before, now I just needed a node to create the rotation.

Matt Taylor. (2018, April 14). Unreal Engine 4 - Quick! How to: Use the basic Rotational Nodes in BP. https://www.youtube.com/watch?v=nbu95VBwe4c&ab_channel=MattTaylor

This video displayed the use of different rotation nodes, the video showed me a large number of choices for the actual setting of the rotation of the object instead of planning the rotation and feeding that into the SetRelativeRotatinon node as I had planned to do.

Moving onto the next video I looked through I found that the majority of tools were made so that the code pulled the rotation of the object, added an amount, and then set the relative rotation of said object using the event tick to actually rotate it continuously. However helpful this new knowledge about different rotation nodes was It wasn’t what I was looking for.

Finally, I found this Reddit post below which outlined the use of a timeline node to play and reverse as ticks passed at run time.

Ryan Chuaa. (2021) Question About rotating an object with a timeline. https://www.reddit.com/r/unrealengine/comments/il1uuh/question_about_rotating_an_object_with_timeline/

AttemptID. (2014) Can you rotate an object with a timeline.  https://forums.unrealengine.com/t/can-you-rotate-an-object-with-a-timeline/287901

With this new information and the forum post linked above I added the timeline and used it with a make rotator to rotate the door along the Z axis when the player moved into the sphere.

After finally being able to make the door rotate smoothly without needing to rely on a tutorial I wanted to add the press of the grab event whilst inside the sphere to then open the door. Unfortunately, after trying to use an AND node and additionally trying to pass the two events through different nodes to get them to function together I realised that I was running out of time and had to leave this part of the feature up to future development.