Unreal Engine 4 学习笔记(六):Actor

Actor是Unreal Engine 4中非常重要的概念,能在Level中显示的物体大多都是Actor。下面对它的一些重要事项进行说明。

AActor的一些重要的派生类继承层级关系

UObject-+
        |-AActor-+
                 |-ABrush----------------+
                 |                       |-AVolume
                 |
                 |-AStaticMeshActor
                 |-ACameraActor
                 |-ANavigationObjectBase-+
                 |                       |-APlayerStart
                 |
                 |-ALight----------------+
                 |                       |-ADirectionalLight
                 |                       |-APointLight
                 |                       |-ASpotLight
                 |
                 |-ATriggerBase----------+
                 |                       |-ATriggerBox
                 |                       |-ATriggerCapsule
                 |                       |-ATriggerSphere
                 |
                 |-AMatineeActor
                 |-AController-----------+
                 |                       |-AAIController
                 |                       |-APlayerController
                 |
                 |-APawn-----------------+
                                         |-ACharacter

AActor中定义的有RootComponent:

USceneComponent* RootComponent;

AActor中一些重要的派生类的说明

APlayerStart
This class indicates a location where a player can spawn when the game begins.
No Player Start: If you try and play your game without adding a Player Start to the world, the player will start from 0,0,0 in the world. Because of this, always make sure that you have a Player Start in your world.
RootComponent = UCapsuleComponent;

AStaticMeshActor
StaticMeshActor is an instance of a UStaticMesh in the world. Static meshes are geometry that do not animate or otherwise deform, and are more efficient to render than other types of geometry.Static meshes dragged into the level from the Content Browser are automatically converted to StaticMeshActors.
RootComponent = UStaticMeshComponent;

ACameraActor
A CameraActor is a camera viewpoint that can be placed in a level.

RootComponent = USceneComponent;
USceneComponent下面附加了UCameraComponent

ATriggerBase
Triggers are Actors that are used to cause an event to occur when they are interacted with by some other object in the level.In other words, they are used to trigger events in response to some other action in the level.All of the default Triggers are generally the same, differing only in the shape of the area of influence - box, capsule, and sphere - used by the Trigger to detect if another object has activated it.
RootComponent = UShapeComponent;

AAIController
AIController is the base class of controllers for AI-controlled Pawns.
Controllers are non-physical actors that can be attached to a pawn to control its actions. AIControllers manage the artificial intelligence for the pawns they control. In networked games, they only exist on the server.

APlayerController
PlayerControllers are used by human players to control Pawns.

ABrush
The Brush Actor is a basic type of Actor that displays simple 3D geometry in the scene. These Actors can be modified using the Geometry Editing mode in the Level Editor. BrushActors (or just Brushes) are commonly used for quickly prototyping environments and blocking out levels for testing gameplay.

RootComponent = UBrushComponent;

Mobility:
The Mobility setting controls whether an Actor will be allowed to move or change in some way during gameplay. This primarily applies to Static Mesh Actors and Light Actors.

以下为可使用各状态的Actor的类型:
Static              Static Mesh Actors,  Light Actors   
Stationary       Light Actors
Movable          Static Mesh Actors, Light Actors  

在实际使用中发现从Geometry中拖放到viewport中的brush对象不像是一个正常的AActor,这点还需要继续研究。

APawn
Pawn is the base class of all actors that can be possessed by players or AI. They are the physical representations of players and creatures in a level.

包含一个UPawnMovementComponent用于处理运行相关逻辑,但需要程序员自己创建

ACharacter
Characters are Pawns that have a mesh, collision, and built-in movement logic. They are responsible for all physical interaction between the player or AI and the world, and also implement basic networking and input models.
They are designed for a vertically-oriented player representation that can walk, jump, fly, and swim through the world using CharacterMovementComponent.
RootComponent = UCapsuleComponent
UCapsuleComponent下面附加了USkeletalMeshComponent


包含一个UCharacterMovementComponent专门用于处理ACharacter运动相关逻辑,同时还设置了UpdatedComponent
UCharacterMovementComponent->UpdatedComponent = UCapsuleComponent;

AActor中一些重要方法

FVector AActor::GetActorForwardVector() const;
FVector AActor::GetActorUpVector() const;
FVector AActor::GetActorRightVector();

实际调用的是rootComponent对应的如下方法:

/** Get the forward (X) unit direction vector from this component, in world space.  */
UFUNCTION(BlueprintCallable, Category="Utilities|Transformation")
FVector USceneComponent::GetForwardVector() const;

/** Get the up (Z) unit direction vector from this component, in world space.  */
UFUNCTION(BlueprintCallable, Category="Utilities|Transformation")
FVector USceneComponent::GetUpVector() const;

/** Get the right (Y) unit direction vector from this component, in world space.  */
UFUNCTION(BlueprintCallable, Category="Utilities|Transformation")
FVector USceneComponent::GetRightVector() const;
/** Returns the transform of the RootComponent of this Actor*/
FTransform AActor::GetActorTransform() const;

/** Returns the location of the RootComponent of this Actor*/
FVector AActor::GetActorLocation() const;

/** Returns the rotation of the RootComponent of this Actor */
FRotator AActor::GetActorRotation() const;

/** Returns the scale of the RootComponent of this Actor */
FVector AActor::GetActorScale() const;

/** Returns the quaternion of the RootComponent of this Actor */
FQuat GetActorQuat() const;

实际调用的是rootComponent对应的如下方法:

/** Get the current component-to-world transform for this component */
FTransform& GetComponentTransform() const;

/** Return location of the component, in world space */
FVector USceneComponent::GetComponentLocation() const;

/** Return rotation of the component, in world space */
FRotator USceneComponent::GetComponentRotation() const;

/** Return scale of the component, in world space */
FVector USceneComponent::GetComponentScale() const;

/** Return rotation quaternion of the component, in world space */
FQuat USceneComponent::GetComponentQuat() const;
/**
 * Get the actor-to-world transform.
 * @return The transform that transforms from actor space to world space.
 */
UFUNCTION(BlueprintCallable, meta=(DisplayName = "GetActorTransform"), Category="Utilities|Transformation")
FTransform AActor::GetTransform()

实际调用的是rootComponent对应的如下方法:

/** Get the current component-to-world transform for this component */
FTransform& GetComponentTransform() const;

参考文档

http://api.unrealengine.com/INT/Engine/Actors/
https://docs.unrealengine.com/en-us/Programming/UnrealArchitecture/Actors

https://docs.unrealengine.com/en-us/Programming/UnrealArchitecture/Actors/ActorLifecycle

猜你喜欢

转载自blog.csdn.net/netyeaxi/article/details/81319171