查看: 372|回复: 7

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

[复制链接]

1

主题

342

帖子

7万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
75866
发表于 2016-6-26 02:01:53 | 显示全部楼层 |阅读模式


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</code> classes is called spawning. This can be done using the generic SpawnActor()</code> function or one of its specialized templated versions.

See Spawning Actors for detailed info on the various methods of creating instances of AActor</code> 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</code> 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()</code> function.

ActorComponents also have the ability to be updated by default, though they use the TickComponent()</code> 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()</code>. 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

主题

894

帖子

2955

积分

vip会员

Rank: 1

积分
2955
发表于 2016-7-2 19:23:41 | 显示全部楼层
很好的东西!
回复 支持 反对

使用道具 举报

0

主题

842

帖子

2810

积分

vip会员

Rank: 1

积分
2810
发表于 2016-7-3 23:08:00 来自手机 | 显示全部楼层
瞧一瞧看一看,看看我又没有!
回复 支持 反对

使用道具 举报

0

主题

847

帖子

2852

积分

vip会员

Rank: 1

积分
2852
发表于 2016-7-4 11:25:03 来自手机 | 显示全部楼层
楼主真是好人吖~~非常感谢
回复 支持 反对

使用道具 举报

0

主题

862

帖子

2832

积分

vip会员

Rank: 1

积分
2832
发表于 2016-7-5 10:17:25 来自手机 | 显示全部楼层
谢谢 分享 这个我还记得 不错
回复 支持 反对

使用道具 举报

0

主题

913

帖子

3036

积分

vip会员

Rank: 1

积分
3036
发表于 2016-7-13 13:14:00 来自手机 | 显示全部楼层
收下了了来了 拉
回复 支持 反对

使用道具 举报

0

主题

961

帖子

3158

积分

vip会员

Rank: 1

积分
3158
发表于 2016-7-18 06:44:43 | 显示全部楼层
看上去不错呀,支持一下
回复 支持 反对

使用道具 举报

0

主题

896

帖子

2976

积分

vip会员

Rank: 1

积分
2976
发表于 2016-7-22 17:49:31 来自手机 | 显示全部楼层
我一天来看一回,看看能不能打折。
回复 支持 反对

使用道具 举报

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

本版积分规则

 
 



邮件留言:


 
返回顶部