I am participating in the nuggets Community game creative submission Contest. For details, please see: Game Creative Submission Contest

preface

I believe many friends who have played the game know that in the process of playing the game, if we are blocked by a door, as long as we press a key, the door will automatically open. So, today I will take you to make a door that will open automatically!

Scenario building

First, find the Walldoor asset in our beginner asset pack and drag it into our scene.

Then select a material to make the wall look more realistic, as shown below:

Next, in our starter pack, find the Wall and drag it into the scene to simulate a stone door and change its size and position to make it look more like a door.

I then added a material to the door to give it a slightly sci-fi look.

Now that we have a door built into the wall, let’s look at how to make the door move.

The target point

Now, our door is still. In order for it to have a range of movement, we need to set a moving target point for the door and make it stop when it moves to this target. So we find TargetPoint in the upper left corner of the editor and drag it into our scene.

I want the door to move to the left as shown in the picture:

Therefore, we set the position of the target point added just now at the final opening position of the gate, as shown in the figure:

Location of target point:

With the target point set, we’ll drag the blueprint.

The blueprint

Open the blueprint for the scene.

Drag and hold the TargetPoint added above into the blueprint.

Then connect the TargetPoint to the GetactorLocation-break Vector in turn in the blueprint, as shown:

Right-click Make Vector and drag the x-coordinate of Break Vector onto the x-coordinate of Make Vector.

Next, drag the Wall object from the scene into the blueprint as well, connecting it to the getactorLocation-break Vector like the TargetPoint above. Because in the scene, our gate only needs to move the X coordinate, and the Y and Z axes do not need to be changed, connect the Y and Z coordinates of the Break Vector to the Y and Z coordinates of the Make Vector.

Right-click the MoveComponentTo function and add it to the blueprint.

Attach the return value of the Make Vector to the TargetRelativeLocation node of the MoveComponentTo, and set the time for the gate to move to 4 seconds.

Right-click add keyboard key E to open the door event response.

Copy the Wall object that we dragged into the blueprint and then go get the GetRootComponent and attach it to the Component, as shown here:

Back in our scene, after selecting our Wall, in the view panel on the right, set the property to Movable, otherwise our gate won’t move because it’s Static by default.

Running effect

The last

Well, this content is over, let’s talk next time.

I am Jie Shao, if you think my writing is good, then please give me a thumbs-up + comments + favorites before leaving oh!

Previous articles:

  • How to use code to control character movement in UE4
  • How to add game characters to UE4 scenes
  • UE4: Android Platform development practice Guide
  • UE4 Development Pit Avoidance Guide (continuously updated)
  • It’s time to start the New Year. Let’s celebrate with a little fireworks
  • Love and Hate with Apple auditors
  • Love and Hate with Apple auditors (Part 1)
  • A common tool of 2021 | 2021 year-end summary
  • Binary tree brush summary: binary search tree properties
  • Binary tree summary: binary tree properties
  • Binary tree summary: binary tree modification and construction
  • StoreKit2 smells this good? Yeah, I tried it. It smells good
  • After reading this article, I am no longer afraid of being asked how to construct a binary tree.
  • The game guys are trying to get people to pay again. That’s bad!
  • Take you rolled a netease holding cloud music home | adapter
  • NetEase Cloud Music Home Page (3)
  • NetEase Cloud Music Home Page (2)
  • NetEase Cloud Music Home Page (a)
  • Does the code need comments? Write and you lose
  • I would not study in Codable for a long time. They are for fun
  • IOS handles web data gracefully. Do you really? Why don’t you read this one
  • UICollectionView custom layout! This one is enough

Please drink a cup ☕️ + attention oh ~

  1. After reading, remember to give me a thumbs-up oh, there is 👍 power
  2. Follow the public number – HelloWorld Jie Shao, the first time push new posture

Finally, creation is not easy, if it is helpful to you, I hope you can praise and support, what questions can also be discussed in the comments section 😄 ~ **