Modelクラス
ひとことで言うと
いくつものパーツをひとまとめにする入れ物です。キャラクターや建物など、複数の部品でできたものはModelになっています。
公式の説明(英語):Models are container objects, meaning they group objects together. They are best used to hold collections of Class.BasePart|BaseParts and have a number of functions that extend their functionality.
使用例
local pad = script.Parent :: BasePart
local target = workspace:WaitForChild("TeleportTarget") :: BasePart
pad.Touched:Connect(function(hit)
local character = hit.Parent
if character and character:IsA("Model") and character:FindFirstChildWhichIsA("Humanoid") then
character:PivotTo(target.CFrame + Vector3.new(0, 5, 0))
end
end)スクリプトは、Luauの型チェック(luau-lsp)で確認しています。
クラスの関係
受け継いでいるクラス:Object → Instance → PVInstance → Model
このクラスを受け継ぐクラス:Actor、BackpackItem、ProceduralModel、Status、WorldRoot
プロパティ(5)
| 名前と書き方 | 説明 |
|---|---|
LevelOfDetailModel.LevelOfDetail: ModelLevelOfDetail | Sets the level of detail on the model for experiences with instance streaming enabled. |
ModelStreamingModeModel.ModelStreamingMode: ModelStreamingMode | Controls the model streaming behavior on Class.Model|Models when instance streaming is enabled. |
PrimaryPartModel.PrimaryPart: BasePart | モデルの基準になるパーツ。PivotToなどで動かすときの基準になります。The primary part of the Model, or nil if not explicitly set. |
ScaleModel.Scale: float | Editor-only property used to scale the model around its pivot. Setting this property will move the scale as though Class.Model:ScaleTo() was called on it. |
WorldPivotModel.WorldPivot: CFrame | Determines where the pivot of a Model which does **not** have a set Model.PrimaryPart is located. |
メソッド(9)
| 名前と書き方 | 説明 |
|---|---|
AddPersistentPlayerModel:AddPersistentPlayer(playerInstance: Player): () | Sets this model to be persistent for the specified player. Class.Model.ModelStreamingMode|ModelStreamingMode must be set to Enum.ModelStreamingMode|PersistentPerPlayer for behavior to be changed as a result of addition. |
GetBoundingBoxModel:GetBoundingBox(): Tuple | Returns a description of a volume that contains all parts of a Model. |
GetExtentsSizeModel:GetExtentsSize(): Vector3 | Returns the size of the smallest bounding box that contains all of the Class.BasePart|BaseParts in the Model, aligned with the Model.PrimaryPart if it is set. |
GetPersistentPlayersModel:GetPersistentPlayers(): List<Player> | Returns all the Player objects that this model object is persistent for. Behavior varies based on whether this method is called from a Script or a LocalScript. |
GetScaleModel:GetScale(): float | Returns the canonical scale of the model, which defaults to 1 for newly created models and will change as it is scaled via Class.Model:ScaleTo(). |
MoveToModel:MoveTo(position: Vector3): () | Moves the Class.Model.PrimaryPart|PrimaryPart to the given position. If a primary part has not been specified, the root part of the model will be used. |
RemovePersistentPlayerModel:RemovePersistentPlayer(playerInstance: Player): () | Makes this model no longer persistent for the specified player. Class.Model.ModelStreamingMode|ModelStreamingMode must be set to Enum.ModelStreamingMode|PersistentPerPlayer for behavior to be changed as a result of removal. |
ScaleToModel:ScaleTo(newScaleFactor: float): () | モデル全体の大きさを、指定した倍率に変えます。Sets the scale factor of the model, adjusting the sizing and location of all descendant Instances such that they have that scale factor relative to their initial sizes and locations when scale factor was 1. |
TranslateByModel:TranslateBy(delta: Vector3): () | Shifts a Model by the given Vector3 offset, preserving the model's orientation. If another BasePart or Terrain already exists at the new position then the Model will overlap said object. |
受け継いでいるメンバー
PVInstance から受け継いでいるもの(4)
Instance から受け継いでいるもの(46)
Archivable・Capabilities・IsInSandbox・Name・Parent・PredictionMode・Sandboxed・AddTag・ClearAllChildren・Clone・Destroy・FindFirstAncestor・FindFirstAncestorOfClass・FindFirstAncestorWhichIsA・FindFirstChild・FindFirstChildOfClass・FindFirstChildWhichIsA・FindFirstDescendant・GetActor・GetAttribute・GetAttributeChangedSignal・GetAttributes・GetChildren・GetDebugId・GetDescendants・GetFullName・GetStyled・GetStyledPropertyChangedSignal・GetTags・HasTag・IsAncestorOf・IsDescendantOf・IsPropertyModified・QueryDescendants・RemoveTag・ResetPropertyToDefault・SetAttribute・WaitForChild・AncestryChanged・AttributeChanged・ChildAdded・ChildRemoved・DescendantAdded・DescendantRemoving・Destroying・StyledPropertiesChanged
Object から受け継いでいるもの(4)
Modelを使う記事
英語の説明とメンバーの一覧は、Roblox Creator Documentation(Model)をもとにしています(CC BY 4.0)。日本語の解説は、このサイトで独自に書いたものです。