BasePartクラス
ひとことで言うと
Part・MeshPartなど、ゲームの世界に置かれる「形のある部品」すべての元になるクラスです。位置・大きさ・色・固定(Anchored)・当たり判定などを決めます。
公式の説明(英語):The abstract base class for in-world objects that physically interact.
BasePart自体は直接作れません(Instance.newで作るのは Part などの子クラスです)。ここにあるプロパティやイベントは、Part・MeshPart・SpawnLocationなどで共通して使えます。
使用例
local part = script.Parent :: BasePart
part.Touched:Connect(function(hit)
local character = hit.Parent
if not character then
return
end
local humanoid = character:FindFirstChildWhichIsA("Humanoid")
if humanoid then
humanoid.Health = 0
end
end)local part = script.Parent :: BasePart
local debounce = false
part.Touched:Connect(function(hit)
if debounce then
return
end
local character = hit.Parent
if not character or not character:FindFirstChildWhichIsA("Humanoid") then
return
end
debounce = true
task.wait(0.5)
part.Transparency = 1
part.CanCollide = false
task.wait(3)
part.Transparency = 0
part.CanCollide = true
debounce = false
end)スクリプトは、Luauの型チェック(luau-lsp)で確認しています。
クラスの関係
受け継いでいるクラス:Object → Instance → PVInstance → BasePart
このクラスを受け継ぐクラス:Terrain、CornerWedgePart、FormFactorPart、TriangleMeshPart、TrussPart、VehicleSeat
プロパティ(40)
| 名前と書き方 | 説明 |
|---|---|
AnchoredBasePart.Anchored: boolean | trueにすると、パーツが空中に固定され、物理の力(重力など)で動かなくなります。Determines whether a part is immovable by physics. |
AssemblyAngularVelocityBasePart.AssemblyAngularVelocity: Vector3 | The angular velocity of the part's assembly. |
AssemblyCenterOfMassBasePart.AssemblyCenterOfMass: Vector3 | The center of mass of the part's assembly in world space. |
AssemblyLinearVelocityBasePart.AssemblyLinearVelocity: Vector3 | パーツ(とつながったパーツ全体)の速度。値を入れると、その方向に飛ばせます。The linear velocity of the part's assembly. |
AssemblyMassBasePart.AssemblyMass: float | The total mass of the part's assembly. |
AssemblyRootPartBasePart.AssemblyRootPart: BasePart | A reference to the root part of the assembly. |
AudioCanCollideBasePart.AudioCanCollide: boolean | Determines whether the part will physically interact with audio simulation, similar to Class.BasePart.CastShadow|CastShadow for lighting. |
BackSurfaceBasePart.BackSurface: SurfaceType | Determines the type of surface for the back face of a part. |
BottomSurfaceBasePart.BottomSurface: SurfaceType | Determines the type of surface for the bottom face of a part. |
BrickColorBasePart.BrickColor: BrickColor | パーツの色を、名前の付いた色(BrickColor)で指定します。Determines the color of a part. |
CanCollideBasePart.CanCollide: boolean | falseにすると、プレイヤーや他のパーツがすり抜けられるようになります。Determines whether a part may collide with other parts. |
CanQueryBasePart.CanQuery: boolean | Determines whether the part is considered during spatial query operations. |
CanTouchBasePart.CanTouch: boolean | falseにすると、Touchedイベントが発生しなくなります。Determines if Class.BasePart.Touched|Touched and Class.BasePart.TouchEnded|TouchEnded events fire on the part. |
CastShadowBasePart.CastShadow: boolean | Determines whether or not a part casts a shadow. |
CenterOfMassBasePart.CenterOfMass: Vector3 | Describes the local position of a part's center of mass, relative to its Class.BasePart.CFrame|CFrame. |
CFrameBasePart.CFrame: CFrame | パーツの位置と向きをまとめて表す値(CFrame)。Determines the position and orientation of the BasePart in the world. |
CollisionGroupBasePart.CollisionGroup: string | Describes the name of a part's collision group. |
ColorBasePart.Color: Color3 | パーツの色(Color3)。Determines the color of a part. |
CurrentPhysicalPropertiesBasePart.CurrentPhysicalProperties: PhysicalProperties | Indicates the current physical properties of the part. |
CustomPhysicalPropertiesBasePart.CustomPhysicalProperties: PhysicalProperties | Determines several physical properties of a part. |
EnableFluidForcesBasePart.EnableFluidForces: boolean | Used to enable or disable aerodynamic forces on parts and assemblies. |
ExtentsCFrameBasePart.ExtentsCFrame: CFrame | The CFrame of the physical extents of the BasePart. |
ExtentsSizeBasePart.ExtentsSize: Vector3 | The actual physical size of the BasePart as regarded by the physics engine. |
FrontSurfaceBasePart.FrontSurface: SurfaceType | Determines the type of surface for the front face of a part. |
LeftSurfaceBasePart.LeftSurface: SurfaceType | Determines the type of surface for the left face of a part. |
LockedBasePart.Locked: boolean | Determines whether a part is selectable in Studio. |
MassBasePart.Mass: float | パーツの重さ。読み取り専用です。Describes the mass of the part, the product of its density and volume. |
MasslessBasePart.Massless: boolean | Determines whether the part contributes to the total mass or inertia of its rigid body. |
MaterialBasePart.Material: Material | パーツの素材(木・金属・ネオンなど)。見た目と音が変わります。Determines the texture and default physical properties of a part. |
MaterialVariantBasePart.MaterialVariant: string | The name of MaterialVariant. |
PivotOffsetBasePart.PivotOffset: CFrame | Specifies the offset of the part's pivot from its CFrame. |
ReflectanceBasePart.Reflectance: float | 反射の強さ。0〜1で指定します。Determines how much a part reflects the skybox. |
ResizeableFacesBasePart.ResizeableFaces: Faces | Describes the faces on which a part may be resized. |
ResizeIncrementBasePart.ResizeIncrement: int | Describes the smallest change in size allowable by the Class.BasePart:Resize()|Resize() method. |
RightSurfaceBasePart.RightSurface: SurfaceType | Determines the type of surface for the right face of a part. |
RootPriorityBasePart.RootPriority: int | The main rule in determining the root part of an assembly. |
RotationBasePart.Rotation: Vector3 | The rotation of the part in degrees for the three axes. |
SizeBasePart.Size: Vector3 | パーツの大きさ(Vector3)。Determines the dimensions of a part (length, height, width). |
TopSurfaceBasePart.TopSurface: SurfaceType | Determines the type of surface for the top face of a part. |
TransparencyBasePart.Transparency: float | 透明度。0で不透明、1で完全に見えなくなります。Determines how much a part can be seen through (the inverse of part opacity). |
メソッド(24)
| 名前と書き方 | 説明 |
|---|---|
AngularAccelerationToTorqueBasePart:AngularAccelerationToTorque(angAcceleration: Vector3, angVelocity: Vector3): Vector3 | Returns the torque needed to achieve a given angular acceleration on this part's assembly, optionally accounting for gyroscopic effects. |
ApplyAngularImpulseBasePart:ApplyAngularImpulse(impulse: Vector3): () | Apply an angular impulse to the assembly. |
ApplyImpulseBasePart:ApplyImpulse(impulse: Vector3): () | パーツに瞬間的な力を加えます。Apply an impulse to the assembly at the assembly's Class.BasePart.AssemblyCenterOfMass|center of mass. |
ApplyImpulseAtPositionBasePart:ApplyImpulseAtPosition(impulse: Vector3, position: Vector3): () | Apply an impulse to the assembly at specified position. |
BindToCollisionSummariesBasePart:BindToCollisionSummaries(callback: Function): RBXScriptConnection | Subscribes to detailed per-frame contact data for the collisions this part is involved in. |
CanCollideWithBasePart:CanCollideWith(part: BasePart): boolean | Returns whether the parts can collide with each other. |
CanSetNetworkOwnershipBasePart:CanSetNetworkOwnership(): Tuple | Checks whether you can set a part's network ownership. |
GetClosestPointOnSurfaceBasePart:GetClosestPointOnSurface(position: Vector3): Vector3 | Returns the closest point on the part's surface to the given point. |
GetConnectedPartsBasePart:GetConnectedParts(recursive: boolean): List<BasePart> | Returns a table of parts connected to the object by any kind of rigid joint. |
GetJointsBasePart:GetJoints(): Instances | Returns all Joints or Constraints connected to this part that are active in the simulation. |
GetMassBasePart:GetMass(): float | Returns the value of the Class.BasePart.Mass|Mass property. |
GetNetworkOwnerBasePart:GetNetworkOwner(): Instance | Returns the current player who is the network owner of this part, or nil in case of the server. |
GetNetworkOwnershipAutoBasePart:GetNetworkOwnershipAuto(): boolean | Returns true if the game engine automatically decides the network owner for this part. |
GetNoCollisionConstraintsBasePart:GetNoCollisionConstraints(): Instances | Returns the enabled NoCollisionConstraint objects currently registered for this part in its physics world. |
GetTouchingPartsBasePart:GetTouchingParts(): Instances | 今ふれているパーツをすべて返します。Returns a table of all BasePart.CanCollide true parts that intersect with this part. |
GetVelocityAtPositionBasePart:GetVelocityAtPosition(position: Vector3): Vector3 | Returns the linear velocity of the part's assembly at the given position relative to this part. |
IntersectAsyncBasePart:IntersectAsync(parts: Instances, collisionfidelity: CollisionFidelity, renderFidelity: RenderFidelity): Instance | Creates a new IntersectOperation from the overlapping geometry of the part and the other parts in the given array. |
IsGroundedBasePart:IsGrounded(): boolean | Returns true if the object is connected to a part that will hold it in place (eg an Class.BasePart.Anchored|Anchored part), otherwise returns false. |
ResizeBasePart:Resize(normalId: NormalId, deltaAmount: int): boolean | Changes the size of an object just like using the Studio resize tool. |
SetNetworkOwnerBasePart:SetNetworkOwner(playerInstance: Player): () | Sets the given player as network owner for this and all connected parts. |
SetNetworkOwnershipAutoBasePart:SetNetworkOwnershipAuto(): () | Lets the game engine dynamically decide who will handle the part's physics (one of the clients or the server). |
SubtractAsyncBasePart:SubtractAsync(parts: Instances, collisionfidelity: CollisionFidelity, renderFidelity: RenderFidelity): Instance | Creates a new UnionOperation from the part, minus the geometry occupied by the parts in the given array. |
TorqueToAngularAccelerationBasePart:TorqueToAngularAcceleration(torque: Vector3, angVelocity: Vector3): Vector3 | Returns the angular acceleration that would result from applying a given torque to this part's assembly, optionally accounting for gyroscopic effects. |
UnionAsyncBasePart:UnionAsync(parts: Instances, collisionfidelity: CollisionFidelity, renderFidelity: RenderFidelity): Instance | Creates a new UnionOperation from the part, plus the geometry occupied by the parts in the given array. |
イベント(2)
| 名前と書き方 | 説明 |
|---|---|
TouchedBasePart.Touched(otherPart: BasePart) | 他のパーツがふれたときに発生するイベントです。ふれたパーツが引数で渡されます。Fires when a part touches another part as a result of physical movement. |
TouchEndedBasePart.TouchEnded(otherPart: BasePart) | ふれていたパーツが離れたときに発生するイベントです。Fires when a part stops touching another part as a result of physical movement. |
受け継いでいるメンバー
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)
BasePartを使う記事
英語の説明とメンバーの一覧は、Roblox Creator Documentation(BasePart)をもとにしています(CC BY 4.0)。日本語の解説は、このサイトで独自に書いたものです。