主题
SpawnLocationUnit
概览
| 字段 | 值 |
|---|---|
| Kind | Unit · 单位 Unit |
| Realm | common |
继承关系
- Unit(5 属性 / 28 函数 / 6 事件)
继承成员
4 个来源 / 59 属性 / 63 函数 / 12 事件
- 来自 WorldUnit(31 属性 / 20 函数 / 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、SetTexture、SetRenderMeshWithDefaultSkin、SetSlotSkinId、GetAllSlotSkinIds、SetSlotModelColor - 事件:
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(1 属性 / 6 函数)
- 来自 Unit(5 属性 / 28 函数 / 6 事件)
- 属性:
AssetId、Name、Desc、Parent、Tags - 函数:
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、HasTag、AddTag、RemoveTag - 事件:
ChildAdded、ChildRemoved、DescendantAdded、DescendantRemoving、AncestryChanged、Destroying
- 属性:
出生点单位用于在场景中标记角色重生的位置,并携带阵营归属、所有者与外观预设等配置。通过 CampId 与 Owner 可以把出生位置绑定到具体阵营或玩家,EggyPrefabId、RenderMeshId、SkinId 与 InheritPrefabAppearance 共同决定出生时使用的形象与皮肤。Capacity 与 RangeBirth 进一步描述该出生点的容纳上限以及是否在范围内出生。
适用场景
在多阵营对战或需要按玩家分配复活位置的地图中,常摆放多个出生点并分别指定阵营、所有者与容纳上限,让角色以对应形象出现在各自位置。
使用要点
先调用 game:CreateUnit("SpawnLocationUnit", config) 或 World:CreateUnit("SpawnLocationUnit", config) 创建实例,配置表中可直接给出 CampId、Owner、Capacity、EggyPrefabId 等字段。拿到实例后通过 spawnUnit.CampId、spawnUnit.Owner、spawnUnit.Capacity 读写配置;需要沿用预设形象时把 spawnUnit.InheritPrefabAppearance 打开,需要指定具体模型与皮肤时改写 RenderMeshId 与 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 | SpawnLocationUnit 的预设形象属性,用于指定该出生点所关联的预设资源标识,取值类型为字符串,默认值为 official://preset/1。 |
InheritPrefabAppearance | Bool | false | 是否继承预设蛋仔的外观。 |
Capacity | Int | 1 | 出生点可容纳的玩家数量上限。 |
RenderMeshId | String | - | SpawnLocationUnit 的 RenderMeshId 属性用于指定该出生点单位所关联的渲染模型资源标识。该属性类型为字符串,属于公开可读写属性,读取该属性可获得当前绑定的渲染模型标识,写入则可替换绑定值。 |
SkinId | String | "" | SkinId 是 SpawnLocationUnit 上的字符串(String)属性,用于保存该出生点单位所使用的皮肤 ID。该属性在 Meta 中登记为公开属性,但未标记为可编辑。 |
Owner | Int | -3 | 出生点所属的玩家 ID。 |
RangeBirth | Bool | - | 控制玩家是否在出生点指定范围内随机出生。 |
