主题
SpawnLocationUnit
概览
| 字段 | 值 |
|---|---|
| Kind | Unit · 单位 Unit |
| Realm | common |
继承关系
- Unit(4 属性 / 25 函数 / 6 事件)
继承成员
4 个来源 / 59 属性 / 58 函数 / 12 事件
- 来自 WorldUnit(29 属性 / 15 函数 / 6 事件)
- 属性:
RenderMeshId、LocalTransparencyModifier、ModelBindParent、TransparentRenderBias、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 - 事件:
OnCollisionEnter、OnCollisionExit、OnLocalCollisionEnter、OnLocalCollisionExit、OnLiftedBegin、OnLiftedEnd
- 属性:
- 来自 BasePart(23 属性 / 9 函数)
- 属性:
CFrame、PivotOffset、Position、Rotation、Scale、Size、ModelAlpha、ModelVisible、CastShadow、ModelColor1、ModelColor2、ModelColor3、ModelColor4、SkinId、UseCustomAppearance、CustomAppearanceId、OcclusionType、AssemblyRootPriority、AssemblyLinearVelocity、AssemblyAngularVelocity、AssemblyMass、AssemblyCenterOfMass、IsStaticOptimization - 函数:
IsNetworkOwnerSide、GetNetworkOwner、SetNetworkOwner、IsWeldConstraintRoot、IsWeldConstraintChild、GetWeldConstraintRootId、GetWeldConstraintId、GetConnectedUnits、SyncRenderToPhysics
- 属性:
- 来自 SpaceUnit(3 属性 / 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
- 属性:
出生点单元用于定义玩家在场景中的初始生成位置与所属阵营。通过设置阵营编号、预设蛋仔外观和容纳上限,可以控制不同队伍的出生区域与角色外观。它还支持范围出生模式,允许玩家在指定区域内随机分布。
适用场景
在多人对战地图中,为红蓝双方分别放置出生点,并指定不同的阵营 ID 和预设蛋仔外观,使玩家加入对应阵营后自动在己方出生点生成。
使用要点
使用 game:CreateUnit("SpawnLocationUnit", config) 创建出生点实例,然后设置 CampId 指定阵营、EggyPrefabId 指定预设蛋仔、Capacity 设置容纳上限。若需范围出生,可将 RangeBirth 设为 true。
注意事项
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 | 出生点所属的阵营 ID。 |
EggyPrefabId | String | official://preset/1 | 预设蛋仔的资源 ID,用于指定在该出生点生成的蛋仔外观。 |
InheritPrefabAppearance | Bool | false | 是否继承预设蛋仔的外观。 |
Capacity | Int | 1 | 出生点可容纳的玩家数量上限。 |
RenderMeshId | String | - | 出生点渲染网格的资源 ID。 |
SkinId | String | "" | 出生点使用的皮肤资源 ID。 |
Owner | Int | -3 | 出生点所属的玩家 ID。 |
RangeBirth | Bool | - | 控制玩家是否在出生点指定范围内随机出生。 |
