当前位置:网站首页>[unreal] key to open the door blueprint notes
[unreal] key to open the door blueprint notes
2022-07-02 10:00:00 【Qiao'an fish】
【 Unreal Engine 】UE4 Automatic door and manual door opening blueprint teaching
Use the previous automatic door opening logic .
Press the specified key , Open door .
The principle is : Game player F build —— Player collision detection —— If the player overlaps with the box shaped collision of the door —— Open door
There are two technical points involved :
- Blueprint communication —— Player blueprint detected door , Tell the door blueprint to execute the opening event .
- collision detection —— Keystrokes , Traverse the objects that players collide , If there is a door , Then execute communication .
One 、 Establish blueprint communication
Blueprint interface —— Blueprint communication bridge
Right click > The blueprint > Blueprint interface .
Create a new function in the blueprint interface If_Open.
At this time, the blueprint interface is set , You can close the blueprint interface window .
Open the interface in the blue diagram of the door : Class settings —— Interface > Add the function just now If_Open
Two 、 Gate logic
1. Press the key to open the door
Open the door blueprint .
add to IF open event , And The opening event is connected .
Now the effect is that players press F Open door , The rear door automatically closes after entering .
If all have to be closed by pressing the key , Record the state of the door , Determine the switch according to the state .
2. Player blueprint settings
Open the player blueprint .
Right click to add F event
F Events are directly connected IF_open Interface , At this time, the direct compilation reports an error , We must give a goal .
3. Player collision detection
Use player capsule for collision detection , For collision Actor Traversal , If there is a door , Then directly execute the door opening event .
Click the capsule component —— Add components to start overlapping events 、 Component end overlap event
Add an array variable to store collisions Actor Information :
- When overlap starts —— Add information
- At the end of the overlap —— Delete the information
When dragging components to overlap “other Actor” The pin is promoted to variable .
Change the variable type to array , Change of name , Delete —— Hold down ctrl Drag variables from the left to the blueprint , Create this variable key .
Drag to open the door Actor Key and create a new ADD“ Add to array ” function —— When components begin to overlap Other Actor Pin 、 The execution pin is connected to the function added to the array .
If the player collides with this object , Then put the Actor Add to the one that can open the door Actor Array .
Drag to open the door Actor Key and create a new Remove“ Remove from array ” function —— When the component ends overlapping Other Actor Pin 、 The execution pin is connected to the function added to the array .
If the player does not collide with this object , Then put the Actor From the one that can open the door Actor Remove from array .
Complete blueprint of collision detection .
4. Collision detection information traversal
At this time, we have the information of the collision object , Next, choose from the inside .
Create a new one that can open the door Actor key , Drag and create For Each Loop Traversal function ——F The event is connected to the traversal function execution pin —— Traversal function and If Open Connected to a
The complete logic is : Press F—— Pair collision Actor Array traversal —— There is a door —— The door blueprint executes the opening event .
Why use arrays , It should be that players may encounter multiple at the same time Actor, Or before leaving the last Actor When they meet new Actor.
边栏推荐
猜你喜欢
随机推荐
C语言之到底是不是太胖了
Junit5 supports suite methods
【虚幻】按键开门蓝图笔记
C语言之判断直角三角形
Judging right triangle in C language
It is the most difficult to teach AI to play iron fist frame by frame. Now arcade game lovers have something
Minimum number of C language
记录一下初次使用Xray的有趣过程
C language: making barrels
Because of hard work, the fruit goes with fate
2837xd code generation module learning (3) -- IIC, ECAN, SCI, watchdog, ECAP modules
三相逆变器离网控制——PR控制
Large neural networks may be beginning to realize: the chief scientist of openai leads to controversy, and everyone quarrels
QT signal slot summary -connect function incorrect usage
Binary and decimal system of C language
C语言之二进制与十进制
【UE5】AI随机漫游蓝图两种实现方法(角色蓝图、行为树)
2837xd Code Generation - stateflow (4)
Navicat 远程连接Mysql报错1045 - Access denied for user ‘root‘@‘222.173.220.236‘ (using password: YES)
Alibaba / popular JSON parsing open source project fastjson2