Vectors and some other basics
a vector - b vector = c vector (vector pointed from b to a vector)
Get the actor forward vector as unit vector
Get the actor position not the unit vector
Click to multiply(dot) = a vector length * b vector length * cos angle
The result is a scalar, which is generally used to judge the object in front and behind (the angle) (the vector length is 1)
cos
(0,1),(school/2,0),(school,-1),(3/2,0)
cos 0°=1
cos 90°=0
cos 180°=-1
The result is positive, then the angle between the two vectors is less than 90 degrees
The result is negative, then the angle between the two vectors is greater than 90 degrees and less than 180 degrees.
Fork multiply(cross) = a vector length * b vector length * sin angle = (y1z2 - y2z1, x2z1 - x1z2, x1y2 - x2y1)
The result is a vector, the angle between a and b is clockwise, the direction is the plane direction downward, the counterclockwise plane direction is upward, the length is the area, and the vector pointing to the vertical plane
% remainder, 5%2=1
Append splicing formatted text
Example: A value 1 B value / C value 2
Print out value 1/value 2
Bullets addedComponentsCan't start physical simulation
The root component must be a collision to enable rebound
Boolean operation
or|| One is true is true
And && is true, that is true
No! True is false is true
Logical execution process control
Sequence logic line division, 1 finish connects 2
Do N starts with index 1
Do Once MultiInput Select the fastest one for multiple logical inputs, reset can be re-execute
Details of variables
Editable instance of a variable = the eye to the right of the variable (in one object, you need to use the variable of another object, you need to select its variable type before selecting its editable instance to be successfully called)
Read-only blueprint If you check it, it cannot be set at runtime
Displayed at generation time (can be displayed at generation time - if ACTOR is generated from this class, there will be an additional subscript of the variable)
If private, the variable in the derived blueprint cannot be modified.
Replication and replication conditions are on the network
function
Function details
Access modifier
Public You can access as long as you hold the current template instance (subclasses are also possible)
Protected The current template instance is not accessible, but subclasses can access it
Private is not accessible
Local variables
Only used in functions, it is a variable acting on the function. When the function is called, the variable is created, the function call ends, and the variable life ends.
Functions and events
The function prohibits delay, and the event can
Functions can have return values, but events do not
Functions have local variables, events do not
Events can be marked as network synchronization, but functions cannot
Events can be bound to the scheduler, but functions cannot
Macro
Macros are text-substituted directly, and macros can be input multiple logic pins and output multiple logic pins.
The local boolean value of the macro starts to enter false
The macro is called in the function, the local data becomes a local variable, the macro is called in the event, the local data becomes a member variable
The function of macros: multiple logical pin input and output can be reduced in the number of variable tags
The difference between functions and macros
Both are reused in encapsulation
Macros are logical node replacements, functions are not
Macros support multi-logical pin input and output, but functions do not work.
Macros will not become compilation units, functions will
Too much use of macros will cause node swelling, and the function will not be understood as a node.
Macros cannot be rewritten, functions can be rewritten (macros are intangible, functions are tangible)
Both functions and macros can build nodes without input and output pins, but in this way, functions are essentially pure functions, and macros are replacement operations.
Macros inside the class cannot be called externally through member objects, functions can
It is not recommended to use macros to write complex logic, but to perform flexible branch process control.
Structure
Record relatively small data, bulf, etc., reduce data replication overhead
Structures that have been encountered Transform Vector Rotate Color
Make structure
break structure
container
All the unreal are homogeneous containers
ArrayContainers (arrays) can automatically change their size
Map containers (map) homogeneous containers with key values (key values can be enumerations) need to rely on key values for element operations, which are operation labels of maps. Key value types can be blueprint regular object types
The element type must be the same and the key value is unique. That is, adding the same key value element will be overwritten
Application: Backpack bar (with grid concept) Skill bar (skill casting shortcut keys) Equipment slot, etc.
Set container (set) key-value homogeneous container. The key value is the same as the element, and it is hidden from the key value operation itself. The operation tag is the element itself, that is, if you want to operate the content in the set, you need to know the element first. This is completely different from the other two containers' ways of thinking. Just check whether the elements exist or not.
Application: Chat insult filtering, creating name-sensitive word search, special prop holding inspection, etc.
Array array
Length gets how many elements there are in the array (responsive to the index and need to be subtracted by one)
Get copy does not change elements in the array, which is safer
Get reference changes original data
Add added at the last position
Insert to an index position in the array
Add makes the unique data not duplicate (repeated and added cannot be added
Append adds the following to the top, the index order remains unchanged and will be repeated
Clear the entire array clear
The content in the Reset grid has not dropped, and there is still grid
Reverse reverse index output
MakeArray dynamically builds arrays at runtime
Contains checks whether there is an element
Find finds the index of this element, no return -1
Remove Index removes elements according to the index, and the remaining rows are left
Remove remove elements by name
Resize specifies the size of the index number, add one, delete elements if there is too much, add 0 if there is too much
Set Array Elem inserts the item in the item into an array with index index. If size to fit is true, when the index position of the inserted element is greater than the array size, the array will be expanded (plus 0 in the blank space) and the insertion fails
Shuffle randomization element position
Swap swaps elements at two indexes
UE4 framework
GameMode Game Mode
The difference between gamemodebase and gamemode is that the latter is more suitable for online games. If you use gamemodebase, you can use gamestatebase.
Build and implement the rules of the game and register other characters in the game (only one copy exists on the server)
Manage the rules of the game
GameState Game Status
Records of shared information in the game (exist on the server and all clients, freely copied to keep it synchronized)
Shared data
DefaulePawn Players
The DefaulePawn will be aligned to Playerstart when the game starts, and the keys can be received by default.
Default player (only objects inherited in Pawn can become default players)
The default player needs to control it through the controller
The God character is controlled, the player controls the character's data and performs actions
PlayerConroller Player Controller
The interface between Pawn and the human player who controls him essentially represents human will (camera, aiming, etc.)
Collect the wishes of real players and finally summarize and transfer them to virtual characters
For example, press W event, PlayerController will pass the W event to Pawn to perform actions
Links, interactive bridges
PlayerState Player Status
The status of a participant in the game, such as a human player or a simulated human playerrobot, AI does not have PlayerState
Record player data (name, score, etc.)
Hud User Interface
Flat-head display—two-dimensional screen display information—UI
HUD has no concept of controls, and UMG can interact with controls.
HUD draws a simple UI, UMG is the main means of user interface development
User Controls
The control needs to be called, and the control needs to be called in the HUD, and it can only be used when displayed in the viewport.
Percentage requires a horizontal box to flow normally
Getting the viewport size is different from getting the mouse position.
Get the viewport size value the same as the get mouse position value in the player controller