查看: 613|回复: 10

[编程指南] 【Actors | Unreal Engine】

[复制链接]

1

主题

338

帖子

7万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
74666
发表于 2016-6-27 01:05:09 | 显示全部楼层 |阅读模式


On this page:

      
Creating Actors

Components

Ticking

Lifecycle

Replication

Destroying Actors
     
An Actor is any object that can be placed into a level. Actors are a generic Class that support 3D transformations such as translation, rotation, and scale. Actors can be created (spawned) and destroyed through gameplay code (C++ or Blueprints). In C++, AActor is the base class of all Actors.

There are several different types of Actors, some examples include: StaticMeshActor, CameraActor, and PlayerStartActor.

Note that actors do not directly store Transform (Location, Rotation, and Scale) data; the Transform data of the Actor's Root Component, if one exists, is used instead.
Creating Actors
Creating new instances of AActor classes is called spawning. This can be done using the generic SpawnActor() function or one of its specialized templated versions.

See Spawning Actors for detailed info on the various methods of creating instances of AActor classes for gameplay.
Components
Actors can be thought of, in one sense, as containers that hold special types of Objects called Components. Different types of Components can be used to control how Actors move, how they are rendered, etc. The other main function of Actors is the replication of properties and function calls across the network during play.

Components are associated with their containing Actor when they are created.

A few of the key types of Components are:
<dl >UActorComponent
This is the base Component. It can be included as part of an Actor. It can Tick if you want it to. ActorComponents are associated with a specific Actor, but do not exist at any specific place in the world. They are generally used for conceptual functionality, like AI or interpreting player input.
USceneComponent
SceneComponents are ActorComponents that have transforms. A transform is a position in the world, defined by location, rotation, and scale. SceneComponents can be attached to each other in a hierarchical fashion. An Actor's location, rotation, and scale are taken from the SceneComponent that is at the root of the hierarchy.
UPrimitiveComponent
PrimitiveComponents are SceneComponents that have a graphical representation of some kind (e.g. a mesh or a particle system). Many of the interesting physics and collision settings are here.

Actors support having a hierarchy of SceneComponents. Each Actor also has a RootComponent property that designates which Component acts as the root for the Actor. Actors themselves do not have transforms, and thus do not have locations, rotations, or scales. Instead, they rely on the transforms of their Components; more specifically, their root Component. If this Component is a SceneComponent, it provides the transformation information for the Actor. Otherwise, the Actor will have no transform. Other attached Components have a transform relative to the Component they are attached to.

An example Actor and hierarchy might look something like this:


GoldPickup Actor
Hierarchy

【虚幻4翻译文档-Actors | Unreal Engine】[虚幻4中文文档]


Root - SceneComponent: Basic scene Component to set the Actor's base location in the world.

StaticMeshComponent: Mesh representing gold ore.

ParticleSystemComponent: Sparkling particle emitter attached to the gold ore.

AudioComponent: Looping metallic chiming audio emitter attached to the gold ore.

BoxComponent: Collision box to use as trigger for overlap event for picking up the gold.
Ticking
Ticking refers to how Actors are updated in Unreal Engine. All Actors have the ability to be ticked each frame, or at a minimum, user-defined interval, allowing you to perform any update calculations or actions that are necessary.

Actors all have the ability to be ticked by default via the Tick() function.

ActorComponents also have the ability to be updated by default, though they use the TickComponent() function to do so. See the Updating section of the Components page for more information.
Lifecycle
See the Actor Lifecycle documentation for more information on how an Actor is created and removed from the game.
Replication
Replication is used to keep the Actors within the world in sync when dealing with networked multiplayer games. Property values and function calls can both be replicated, allowing for complete control over the state of the game on all clients.
Destroying Actors
Actors are not generally garbage collected, as the World Object holds a list of Actor references. Actors can be explicitly destroyed by calling Destroy(). This removes them from the level and marks them as "pending kill", which means they will hang around until they are cleaned up on the next garbage collection.
回复

使用道具 举报

0

主题

948

帖子

3135

积分

vip会员

Rank: 1

积分
3135
发表于 2016-7-2 19:37:59 来自手机 | 显示全部楼层
好东西这么多....
回复 支持 反对

使用道具 举报

0

主题

904

帖子

2940

积分

vip会员

Rank: 1

积分
2940
发表于 2016-7-3 11:50:28 来自手机 | 显示全部楼层
看看, 顶起. 谢谢楼主
回复 支持 反对

使用道具 举报

0

主题

851

帖子

2762

积分

vip会员

Rank: 1

积分
2762
发表于 2016-7-4 07:28:38 来自手机 | 显示全部楼层
恩,好资源~ 哈哈~
回复 支持 反对

使用道具 举报

0

主题

861

帖子

2807

积分

vip会员

Rank: 1

积分
2807
发表于 2016-7-6 10:47:18 | 显示全部楼层
什么鬼???看着很不错的样子啊!
回复 支持 反对

使用道具 举报

0

主题

898

帖子

2941

积分

vip会员

Rank: 1

积分
2941
发表于 2016-7-15 19:57:44 | 显示全部楼层
看看价钱,然后考虑。
回复 支持 反对

使用道具 举报

0

主题

845

帖子

2811

积分

vip会员

Rank: 1

积分
2811
发表于 2016-7-16 06:48:14 | 显示全部楼层
恩,好资源~ 哈哈~
回复 支持 反对

使用道具 举报

0

主题

827

帖子

2719

积分

vip会员

Rank: 1

积分
2719
发表于 2016-7-17 12:26:53 来自手机 | 显示全部楼层
资源都让你发了。
回复 支持 反对

使用道具 举报

0

主题

841

帖子

2789

积分

vip会员

Rank: 1

积分
2789
发表于 2016-7-18 06:53:07 | 显示全部楼层
支持一下,3q
回复 支持 反对

使用道具 举报

0

主题

935

帖子

3091

积分

vip会员

Rank: 1

积分
3091
发表于 2016-7-18 11:15:27 来自手机 | 显示全部楼层
啊啊啊啊,好多好多好多
回复 支持 反对

使用道具 举报

*滑块验证:
您需要登录后才可以回帖 登录 | enginedx注册

本版积分规则

 
 



邮件留言:


 
返回顶部