天天看點

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

繼續閱讀