[Super detailed nanny-level ue4 notes (blueprint)! Instant updates~]

Blueprint

Table of contents

Blueprint basic logic

Blueprint visual programming - door opening and closing interaction implementation

Create a door blueprint class - the difference between Actor and component, door and pivot point modification

Blueprint visual programming - pressing the button to open and close the door

Blueprint visual programming - mouse click to open and close the door



Knowledge point 1: Blueprint is visual programming

Knowledge point 2: Blueprint is an object-oriented compiled visual programming language

Knowledge point 3: The difference between level blueprint and blueprint class

       Level Blueprints are tools used to create levels or scenes in your game. It allows game developers to create objects in Blueprints, set physical properties, add game logic, and more to build a complete game level.

       Blueprint classes are tools for creating reusable code, functions, and algorithms. It allows game developers to create custom classes, define functions and variables, etc. in Blueprints so that they can be called multiple times and reused in the game.

       The difference between level blueprints and blueprint classes lies in the scope of their control and the degree to which they can be modified. The level blueprint only controls the objects and behaviors in the current level and can be modified in real time; while the blueprint class defines all the information of the game object and cannot be modified during the game, but can be used in different levels.

Knowledge point 4: Blueprint data type

  • The Boolean type corresponding to the red horizontal bar
  • The integer corresponding to the green horizontal bar
  • The floating point type corresponding to the light green horizontal bar
  • The string type corresponding to the rose red horizontal bar

Add little white person third person to operate

Give little white people control over the scene: details—self—poss—player 0


 

Blueprint basic logic

       In the content of the blueprint, we mainly use the sidebar and the middle viewport area. The upper part of the toolbar contains the two words "Blueprint", the main content of today's course. Click the left mouse button to expand the analysis. Option, select the level blueprint and click the left mouse button again. The interface you enter is the editing interface of the level blueprint.

  • Right-click in the level blueprint to expand the node search bar

  • Type BeginPlay, capitalization does not matter, select the event BeginPlay, click the left mouse button to select

  • Right-click again to expand the node search bar, type PrintString, and select the PrintString node with grayed out background.

  • Press the left mouse button on the white triangular pin on the right side of the BeginPlay node and pull out a signal line, connect it to the white triangular pin on the left side of the PrintString node.

  • At the same time, modify the Hello in the middle of the PrintString node to what you want to print on the screen, for example: Hello, blueprint

 

      In the Unreal Engine 4 engine, the implementation of the program is executed by transmitting signals through node connections. The two nodes we see have white triangular pins, collectively called execution pins, and the execution pins on the left The pin is called the input pin , and the execution pin on the right is called the output pin . The BeginPlay node does not have an input on the left, which means it is a pure output node. Its function is to release when the play button is pressed, which is when the game starts. A signal goes to the input pin of the next node connected through the signal line, causing it to have an effect . At the same time, after the next node completes its function, it will continue to transmit the signal to the next node along the connection, pointing to the signal line. Terminate, the logic of this section is executed.


Blueprint visual programming - door opening and closing interaction implementation

How does a sensor door work in life? The sensor door first has a sensor device that senses the approach of a person, and the door automatically opens. When the person moves away, the door automatically closes. The same applies to the door in the game, and then ue4 It's called a box trigger.

Sensor in real life - ue4 box trigger.

Required keywords: Level blueprint - write some interactions, events, and collisions in the scene

Case 1 Interactive display of opening and closing doors

  • Required: Add New Item - Content Pack - strarter Content - SM Door

  • (Just added it will wear through the mold, you need to add collision to block the character)

  • Collision: Open door model. Collision - Add a box to simplify collision (after adding collision, player0 cannot walk through the door)

  • Adjust the collision size: shortcut R zoom + pull size (the collision size is the range where player0 cannot move after hitting the door)

  • Box Trigger: Mode - Basic - Box Trigger

  • (The operation of opening the door appears within the range of the box trigger, with a green border)

  • Modify the door to be movable: select the door - Transform - Movable

  • Click the box trigger - toolbar - blueprint - open level blueprint - right click

  • Click on the door - create a reference to the door - set actor rotation - change the z-axis to 85 degrees (tell the system to rotate the door target 85 degrees around the y-axis)

  • (After saving and running, you will find that the trigger will open when player0 is close to the door/box)

  • Create a new timeline - double-click to add a floating point track - right-click to add keyframe 1 (time 0, value 0) - add keyframe (time 2, value 85) (the value is based on the angle of rotation)

  • Right-click keyframe 1 and click Auto, right-click keyframe 2 and click Auto (in order to smooth the opening of the door)

  • connecting lines

  • Timeline meaning:


Create a door blueprint class - the difference between Actor and component, door and pivot point modification

When there are many things on the screen, creating a trigger for each door and then writing the level blueprint will make the workload very heavy, so you can create an Actor to facilitate subsequent operations.

Understanding: Actor can be understood as a category

Case 1 - Interactive display of opening and closing doors

  • Right-click - Blueprint Class - Actor - New Door_BP - Double-click to open (there are many components in Actor, which can be understood as human clothes, hats and pants)

  • Add component 1 - Skeletal Mesh (static mesh = model) - named DoorFrame

  • Static Mesh——SM_DoorFrame

    • Add component 2 - Skeletal Mesh (static mesh = model) - named Door

    • Static Mesh——SM_Door

 

  • Add box Collision (box collision (box trigger)) - adjust the size of the collision box (put the box collision and the door at the same level. If they are not placed at the same level, the trigger box will also move when the door moves, and the door Once opened, people within the range of the moving trigger box will have no way to close the door)

  • Write event chart - click box - event - on Component Begin Overlap - on Component End Overlap - timeline - add keyframe 1 (0, 0) - add keyframe 2 (1.5, 75) - —Length 2—Right-click automatic (on Component Begin Overlap within the collision box, on Component End Overlap outside the scope of the collision box)

  • Set rotation relative to position:

SetRelativeRotation: Set the rotation of the relative position. The relative position, such as the position of the door and door frame, does not change. A single component rotates on its own axis.

SetWorldRotation: The world coordinates will not be changed. The coordinates are always 0, 0, 0. A single component rotates based on the world axis.

SetActorRotation: self rotates the entire blueprint class, no matter how many components there are


Blueprint visual programming - pressing the button to open and close the door

In game operations, the keyboard is generally used to open and close doors.

Case - game button e opens the door

node:

1..Enable Input (enable input)

2.Disable Input (disable output)

3.Get Player Controller (get player controller)

[In short, the above three combinations specify a control character (Get Player Controller), which determines whether the blueprint can accept or reject instructions from the keyboard of the player operating the character: enable input (Enable Input), disable input (Disable Input), Once the character meets the trigger conditions, input is enabled or disabled, that is, the character can gain or lose the right to input keys from the keyboard (in this case, the following case is the mouse, to summarize, input from the device should be accepted), and then trigger There’s a mess in the back]

4. E (E button)

5. Under the premise of Gate (when Open or Close is satisfied), the event is triggered when E (Enter) is entered.

6. Flip Flop (continuous flipping, A and B are executed in turn, the first call executes A, the second call B, the third call A...)

7. SetRelativeRotation (set relative position rotation)


Blueprint visual programming - mouse click to open and close the door

Case - click the mouse to open the door

1. Add On Clicked (when clicked), click Door - Event - On Clicked (the event will be triggered when the model is clicked)

2. Open World Settings - Window, World Settings - Game Mode

 

 

3. Display the mouse when the character is close

 

Guess you like

Origin blog.csdn.net/qq_45206556/article/details/131528797