Actor组件、场景组件、基元组件的区别(Actor Component vs Scene Component vs PrimitiveComponents)
问题1:
这两者之间有什么区别?当我想给Actor一个有功能的静态网格体的组件时,我应该使用哪个?
What’s the difference between the two? When I want to give an actor a component that has functionality and/or static meshes, which should I use?
回答:
我认为,如果你想把StaticMeshes添加给父Actor,你可能需要一个子Actor组件。组件通常只与关联的Actor一起执行功能,如果您想要,您可以将组件的网格引用传递给Actor,以便创建StaticMesh组件。不过一般来说,子Actor是为了将附加组件的功能附加到另一个Actor而设计的。
具有变换(Transform)的Actor组件 称为 场景组件(SceneComponents) ,可以渲染的Actor组件 称为 基元组件(PrimitiveComponents)。
因此,基本上 Actor组件 用于最基本的功能,不需要访问变换(位置、旋转、缩放)属性,而 场景组件 允许相对父Actor移动子组件等操作。
I think you may want a Child Actor Component if youre wanting to give StaticMeshes to a parent Actor. Components typically only do functionality with an associated Actor, you could pass mesh references from a component to the Actor for creation of the StaticMesh Components on that end of things if thats what youre after. Generally speaking though Child Actors are designed for attaching functionality with additional components to another Actor.
ActorComponents that have a transform are known as SceneComponents and those that can be rendered are PrimitiveComponents.
So basically ActorComponents are for the most basic of functionality which doesnt require access to a transform (location, rotation, scale) and SceneComponents allow things like moving all child components relative to the parent Actor.
问题2
“原始组件”到底是什么?我应该什么时候使用它们?
What the “Primitive components” actually are? And when should I use them?
回答
基元组件(PrimitiveComponents) 是包含或生成某种几何图形的场景组件,通常用于渲染或用作碰撞数据。各种类型的几何图形有几个子类,但到目前为止最常见的是胶囊组件(CapsuleComponent)、静态网格体(StaticMeshComponent)和骨骼网格体(SkeletalMeshComponent)。胶囊组件生成用于碰撞检测的几何图形,但不会呈现;而静态网格体和骨骼网格体包含预构建的几何图形,这些几何图形是渲染的,但也可用于碰撞检测。
PrimitiveComponents are SceneComponents that contain or generate some sort of geometry, generally to be rendered or used as collision data. There are several subclasses for the various types of geometry, but the most common by far are the CapsuleComponent, StaticMeshComponent, and SkeletalMeshComponent. CapsuleComponents generate geometry that is used for collision detection, but not rendered; while StaticMeshComponents and SkeletalMeshComponents contain pre-built geometry that is rendered, but can also be used for collision detection.
场景组件(SceneComponents) 就是带着Transform的Actor组件,因此场景组件可以相对其附着的Actor有相对位移、旋转或者缩放。比如:弹簧臂组件(SpringArm) 可以相对角色有位置偏移。
基元组件(PrimitiveComponents) 是能被渲染的场景组件,是包含或生成某种几何图形的场景组件。比如:胶囊组件(CapsuleComponent)、静态网格体(StaticMeshComponent)和骨骼网格体(SkeletalMeshComponent)。胶囊组件生成用于碰撞检测的几何图形,但不会在游戏中显示;而网格体组件包含预构建的几何体(模型),这些几何体会被渲染,也可用于碰撞检测。