当前位置:网站首页>UE4 actor Basics
UE4 actor Basics
2022-06-27 19:58:00 【Lao Yan is trying】
1.Actor Life cycle of
1.Actor The creation of
a. Load from disk , It is applicable to Actor establish .
Create a process :
1.LoadMap or AddToWorld Called
2. Load... From disk Actor
3. perform PostLoad, You can perform custom versioning and repair operations .
4.InitializeActorsForPlay: initialization Actor
5. For uninitialized Actor perform RouteActorInitialize
6. Initialize components :PreInitializeComponents - stay Actor Called on a component of InitializeComponent Call before
InitializeComponent - Actor Create helper function for each component defined on .
PostInitializeComponents - Actor After the component of is initialized, call
7.BeginPlay - Call after the level starts
b. Copy... From the editor .
Create a process :
1. In the editor Actor Be copied into the new world scene
2.PostDuplicate Called
3.InitializeActorsForPlay: initialization Actor
4. For uninitialized Actor perform RouteActorInitialize
5. Initialize components : ditto
6.BeginPlay - Call after the level starts
c. example Actor
Create a process :
1.SpawnActor Called
2.PostSpawnInitialize
3.PostActorCreated The build function class behavior occurs here .PostActorCreated And PostLoad Mutually exclusive .
4.ExecuteConstruction:OnConstruction - Actor The construction of . The blueprint Actor Components of are created here , The blueprint variable is initialized here
5.PostActorConstruction
6. Initialize components : ditto
7.OnActorSpawned stay UWorld Play on
8.BeginPlay - Call after the level starts
d. Delay generation , Set any attribute to “Expose on Spawn” You can delay Actor Generation .
Create a process :
1.SpawnActorDeferred - Generate programmed Actor, Make additional settings before the blueprint build script
2.PostSpawnInitialize
3.PostActorCreated The build function class behavior occurs here .PostActorCreated And PostLoad Mutually exclusive .
4. Through a valid but incomplete Actor Instance settings / Call multiple “ Initialization function ”
5.FinishSpawningActor - Post call pair Actor To be finalized , stay Spawn Actor Select from row ExecuteConstruction.
6.ExecuteConstruction:OnConstruction - Actor The construction of . The blueprint Actor Components of are created here , The blueprint variable is initialized here
7.PostActorConstruction
8. Initialize components : ditto
9.OnActorSpawned stay UWorld Play on
10.BeginPlay - Call after the level starts
2.Actor Destruction of
Destruction process :
a.EndPlay - Call... In several places , Guarantee Actor My life is coming to an end . call EndPlay The whole situation of :
1. Yes Destroy Explicit call
2.Play in Editor End
3. Level transition ( Seamless travel or loading maps ) contain Actor The flow level of is unloaded
4.Actor Your life is over
5. Application shutdown ( All Actor Be destroyed )
b. No matter how these situations occur ,Actor Will be marked as RF_PendingKill, So it will be deallocated in the next garbage collection cycle .
c. An object is marked for destruction for a period of time , Garbage collection actually removes it from memory , Release the resources it uses . Destruction process :
1.BeginDestroy - Object can take advantage of this opportunity to free memory and process other multithreaded resources ( This is the image thread proxy object ).
2.IsReadyForFinishDestroy - The garbage collection process will call this function , To determine whether an object can be permanently deallocated .
3.FinishDestroy - Finally the object will be destroyed , This is another opportunity to free up internal data structures .
2. Components :
1. A component is a special type of object , As Actor Child objects in use .
2.ActorComponent Is the basic class of the component , Definitions can be added to different types Actor The reuse behavior of .
3. To make ActorComponent Every frame updates and affects the scene , They must be registered with the scene . call UActorComponent::RegisterComponent() Registration can be performed .
4. You can also cancel ActorComponent Registration of , Avoid them being updated 、 simulation , Or render . call UActorComponent::UnregisterComponent() You can cancel the component registration .
5.ActorComponent Through its TickComponent() Function to update every frame .
3. Generate Actor:
1. Create a new Actor The process of the example is called generation . Generate Actors The process is to use UWorld::SpawnActor() Function completed .
2.SpawnActor The structure of the class is as follows :
AActor* UWorld::SpawnActor
(
UClass* Class, Indicate the to be generated Actor Class .
FName InName, Used as generated Actor The name of .
FVector const* Location, Used as generated Actor Initial position .
FRotator const* Rotation, Used as generated Actor Initial rotation of .
AActor* Template, Used as generated Actor The template used when . The generated Actor The template will be used Actor Property value of the .
bool bNoCollisionFail, Decide to generate Actor Whether to carry out collision test . If true, It's generating Actor Do not conduct crash test .
bool bRemoteOwned,
AActor* Owner, Have the generated Actor Of AActor.
APawn* Instigator, Resulting in the generated Actor A aggressor who inflicts harm .
bool bNoFail, Determines if certain conditions are not met , Generate Actor Failure or not .
ULevel* OverrideLevel, Specify generation Actor Of Ulevel, That is to say Actor External container for .
bool bDeferConstruction, Decide whether to run the build script .
)
3.SpawnActor() Function usage :
AKAsset* SpawnedActor1 = (AKAsset*) GetWorld()->SpawnActor(AKAsset::StaticClass(), NAME_None, &Location);
4.Actor Ticking:
1.Tick Means at regular intervals ( Usually once per frame ) In a actor Or run a piece of code or blueprint script on a component .
2.Actors And components can be set to each frame tick, It can also be set at the lowest time interval tick, Or not at all tick. Besides , They can be combined into groups at different stages of the engine's update cycle per frame ; Separate instructions may also be accepted , Waiting for a specific tick When it's done, start again .
3.Tick Groups can be specified in code or blueprints . Every tick The group will complete each of the specified actor And components tick, Then start the next tick Group .
4. Can have playful tick Group has :
a.TG_PrePhysics:Actor With physical objects ( Including physical based attachments ) Used when interacting tick Group .
this tick The physical simulation data in belongs to the previous frame — That is, the data rendered to the screen in the previous frame .
b.TG_DuringPhysics: this tick The group only recommends logic that ignores physical data or allows a frame deviation .
c.TG_PostPhysics: This group can be used for weapon or motion tracking . When you render this frame, all physical objects will be in their final position .
d.TG_PostUpdateWork: This group can send the most backward information to the particle system .
5. stay BeginPlay in ,actor Will register its master with the engine tick Functions and their components tick function .Actor Of tick The function can be passed through PrimaryActorTick Members are set to be in a specific tick Run in group , Or completely disable .
The code is as follows :
PrimaryActorTick.bCanEverTick = true;
PrimaryActorTick.bTickEvenWhenPaused = true;
PrimaryActorTick.TickGroup = TG_PrePhysics;
Components Tick The function code is as follows :
PrimaryComponentTick.bCanEverTick = true;
PrimaryComponentTick.bTickEvenWhenPaused = true;
PrimaryComponentTick.TickGroup = TG_PrePhysics;
6. Be careful :PrimaryActorTick Use Actor Of Tick() function , and PrimaryComponentTick Use ActorComponent Of TickComponent() function .
边栏推荐
- 【debug】平台工程接口调试
- Cdga | what is the core of digital transformation in the transportation industry?
- MASS幸运哈希游戏系统开发丨冲突解决方法(代码分析)
- [bug] Lenovo Xiaoxin has a problem. Your pin is unavailable.
- Crawl national laws and Regulations Database
- [bug] there is an error uploading the picture (413 request entity too large)
- 数仓的字符截取三胞胎:substrb、substr、substring
- 券商经理的开户二维码开户买股票安全吗?有谁知道啊
- 429-二叉树(108. 将有序数组转换为二叉搜索树、538. 把二叉搜索树转换为累加树、 106.从中序与后序遍历序列构造二叉树、235. 二叉搜索树的最近公共祖先)
- shell脚本常用命令(三)
猜你喜欢

数仓的字符截取三胞胎:substrb、substr、substring

Observable, reliable: the first shot of cloudops series Salon of cloud automation operation and maintenance

Bit.Store:熊市漫漫,稳定Staking产品或成主旋律

429-二叉树(108. 将有序数组转换为二叉搜索树、538. 把二叉搜索树转换为累加树、 106.从中序与后序遍历序列构造二叉树、235. 二叉搜索树的最近公共祖先)

键入网址到网页显示,期间发生了什么?

《第五项修炼》(The Fifth Discipline):学习型组织的艺术与实践

Adding, deleting, modifying and querying MySQL tables (basic)

Data intelligence enters the "deep water area", and data governance is the key

带你认识图数据库性能和场景测试利器LDBC SNB

【bug】联想小新出现问题,你的PIN不可用。
随机推荐
MySQL表的增删改查(基础)
The Fifth Discipline: the art and practice of learning organization
crontab的学习随笔
Tupu digital twin intelligent energy integrated management and control platform
海底电缆探测技术总结
SQL Server - Window Function - 解决连续N条记录过滤问题
1023 Have Fun with Numbers
Summary of submarine cable detection technology
作为软件工程师,给年轻时的自己的建议(下)
1029 Median
从感知机到前馈神经网络的数学推导
流程判断-三目运算-for循环
Talk about graduation season
Pyhton爬取百度文库文字写入word文档
嵌入式软件开发中必备软件工具
金鱼哥RHCA回忆录:DO447管理项目和开展作业--创建作业模板并启动作业
On thread safety
从指令交读掌握函数调用堆栈详细过程
1028 List Sorting
现在网上买股票开户身份证信息安全吗?