主题
SpawnLocationUnit
概览
| 字段 | 值 |
|---|---|
| Kind | Unit · 单位 Unit |
| Realm | common |
继承关系
- Unit(4 属性 / 25 函数 / 6 事件)
继承成员
4 个来源 / 59 属性 / 59 函数 / 12 事件
- 来自 WorldUnit(31 属性 / 16 函数 / 6 事件)
- 属性:
LocalTransparencyModifier、ModelBindParent、TransparentRenderBias、UseSkinList、SkinSlots、PhysicsMeshId、BodyType、PhysicsActive、CollisionGroup、CanCollide、CanTouch、CanTrigger、Mass、Massless、CustomPhysicalProperties、CenterOfMass、GravityEnabled、UseIndividualGravity、IndividualGravityValue、LinearDamping、AngularDamping、AngularVelocity、LinearVelocity、Climbable、Liftable、UseCustomThrownAngle、CustomThrownAngle、UseCustomThrownForce、CustomThrownForce、CanQuery - 函数:
AddCollisionWithGroup、RemoveCollisionWithGroup、GetCollisionWithGroups、ApplyForceToCenterOfMass、ApplyForceAtLocalPosition、ApplyForceAtWorldPosition、ApplyTorque、ApplyImpulse、ApplyImpulseAtLocalPosition、ApplyImpulseAtWorldPosition、GetVelocityAtPosition、AddNoCollisionPairWithUnit、RemoveNoCollisionPairWithUnit、RemoveAllNoCollisionPairWithUnit、GetNoCollisionPairUnitList、SetRenderMeshWithDefaultSkin - 事件:
OnCollisionEnter、OnCollisionExit、OnLocalCollisionEnter、OnLocalCollisionExit、OnLiftedBegin、OnLiftedEnd
- 属性:
- 来自 BasePart(24 属性 / 9 函数)
- 属性:
CFrame、PivotOffset、Position、Rotation、Scale、Size、ModelAlpha、ModelVisible、CastShadow、ModelColor1、ModelColor2、ModelColor3、ModelColor4、UseCustomAppearance、CustomAppearanceId、OcclusionType、AssemblyRootPriority、AssemblyLinearVelocity、AssemblyAngularVelocity、AssemblyMass、AssemblyCenterOfMass、Persistent、IsStaticOptimization - 函数:
IsNetworkOwnerSide、GetNetworkOwner、SetNetworkOwner、GetNetworkOwnershipAuto、SetNetworkOwnershipAuto、IsWeldConstraintRoot、IsWeldConstraintChild、GetConnectedUnits、SyncRenderToPhysics
- 属性:
- 来自 SpaceUnit(2 属性 / 9 函数)
- 来自 Unit(4 属性 / 25 函数 / 6 事件)
- 属性:
AssetId、Name、Desc、Parent - 函数:
ClearAllChildren、GetChildren、GetDescendants、IsAncestorOf、IsDescendantOf、FindFirstAncestor、FindFirstAncestorWhichIsA、FindFirstAncestorOfClass、FindFirstChild、FindFirstChildWhichIsA、FindFirstChildOfClass、HasChildren、GetChildCount、GetChildAtIndex、SetAttribute、GetAttribute、GetAllProps、Clone、IsA、Destroy、GetPropertyChangedSignal、GetAttributeChangedSignal、FindFromPath、GetFullPath、GetDebugId - 事件:
ChildAdded、ChildRemoved、DescendantAdded、DescendantRemoving、AncestryChanged、Destroying
- 属性:
SpawnLocationUnit 用于在场景中标记出生位置,并决定该出生点的阵营归属、所属玩家以及可容纳的人数上限。它同时承担出生表现配置,包括出生时使用的预设蛋仔、渲染网格与皮肤,以及是否继承预设外观。借助范围出生开关,还可以控制出生点是否采用范围内出生的方式。
适用场景
常用于对局准备阶段按阵营或玩家布置出生点:先创建出生点并设置 CampId 与 Owner,再让其承载出生逻辑;也常用于运行过程中调整已有出生点的 Capacity 或外观配置。
使用要点
通过 game:CreateUnit("SpawnLocationUnit", config) 或 World:CreateUnit("SpawnLocationUnit", config) 创建实例,在配置中传入 CampId、Owner、EggyPrefabId、Capacity 等字段。创建完成后可直接读写实例属性,例如 spawnUnit.Capacity、spawnUnit.RangeBirth、spawnUnit.RenderMeshId。若需要更换出生时的表现,可继续修改 InheritPrefabAppearance、EggyPrefabId 与 SkinId。
注意事项
Capacity 表示公开契约中的容纳上限;具体超容量分配策略未在 Meta 中声明,不应在脚本中依赖某种固定行为。若编辑器属性面板中不易定位 Capacity,可在脚本中通过 spawnUnit.Capacity 直接读取或设置。
代码示例
创建指定阵营的出生点
lua
-- @runtime server
local world = game:GetService("World")
local spawn = world:CreateUnit("SpawnLocationUnit", {
Name = "Team1Spawn",
CampId = 1,
Capacity = 4,
EggyPrefabId = "official://preset/1",
InheritPrefabAppearance = true,
Position = Vector3.New(0, 2, 0),
})
print("出生点阵营:", spawn.CampId, "容量:", spawn.Capacity)属性 (8)
| Name | 类型 | 默认值 | 说明 |
|---|---|---|---|
CampId | Int | 1 | CampId 是 SpawnLocationUnit 上的整数(Int)属性,用于标识该出生点单位所属的阵营编号。该属性在 Meta 中登记为公开、可编辑、非只读,作者可以读取当前值,也可以写入新的阵营编号。 |
EggyPrefabId | String | official://preset/1 | 预设蛋仔的资源 ID,用于指定在该出生点生成的蛋仔外观。 |
InheritPrefabAppearance | Bool | false | 是否继承预设蛋仔的外观。 |
Capacity | Int | 1 | 出生点可容纳的玩家数量上限。 |
RenderMeshId | String | - | SpawnLocationUnit 的 RenderMeshId 属性用于指定该出生点单位所关联的渲染模型资源标识。该属性类型为字符串,属于公开可读写属性,读取该属性可获得当前绑定的渲染模型标识,写入则可替换绑定值。 |
SkinId | String | "" | SkinId 是 SpawnLocationUnit 上的字符串(String)属性,用于保存该出生点单位所使用的皮肤 ID。该属性在 Meta 中登记为公开属性,但未标记为可编辑。 |
Owner | Int | -3 | 出生点所属的玩家 ID。 |
RangeBirth | Bool | - | 控制玩家是否在出生点指定范围内随机出生。 |
