MeshPart
MeshPart is a form of BasePart that includes a physically simulated custom mesh. Unlike with other mesh classes, such as SpecialMesh and BlockMesh, they are not parented to a BasePart but rather behave as a BasePart in their own right.
The mesh and texture of a MeshPart are determined by the MeshId and TextureID properties. For more information, see Meshes.
Summary
Properties
Determines whether to render both faces of polygons in the mesh.
The mesh that is displayed on the MeshPart. Supports asset URIs and EditableMesh objects.
The asset URIs of the mesh that is displayed on the MeshPart. Reads and writes to MeshContent.
The level of detail used to render the MeshPart.
The texture applied to the MeshPart. Supports asset URIs and EditableImage objects.
The texture applied to the MeshPart. Reads and writes to TextureContent.
Determines the level of detail the part's physics will adhere to its mesh.
Determines the geometric representation used to compute aerodynamic forces and torques.
Determines whether a part is immovable by physics.
The angular velocity of the part's assembly.
The center of mass of the part's assembly in world space.
The linear velocity of the part's assembly.
The total mass of the part's assembly.
A reference to the root part of the assembly.
Determines the type of surface for the Back face of a part (+Z direction).
Determines the type of surface for the Bottom face of a part (-Y direction).
Determines the color of a part.
Determines the position and orientation of the BasePart in the world.
Determines whether a part may collide with other parts.
Determines whether the part is considered during spatial query operations.
Determines if Touched and TouchEnded events fire on the part.
Determines whether or not a part casts a shadow.
Describes the world position in which a part's center of mass is located.
Describes the name of a part's collision group.
Determines the color of a part.
Indicates the current physical properties of the part.
Determines several physical properties of a part.
Used to enable or disable aerodynamic forces on parts and assemblies.
The actual physical size of the BasePart as regarded by the physics engine.
Determines the type of surface for the Front face of a part (-Z direction).
Determines the type of surface for the Left face of a part (-X direction).
Determines a multiplier for BasePart.Transparency that is only visible to the local client.
Determines whether a part is selectable in Studio.
Describes the mass of the part, the product of its density and volume.
Determines whether the part contributes to the total mass or inertia of its rigid body.
Determines the texture and default physical properties of a part.
The name of MaterialVariant.
Describes the rotation of the part in the world.
Specifies the offset of the part's pivot from its CFrame.
Describes the position of the part in the world.
Time since last recorded physics update.
Determines how much a part reflects the skybox.
Describes the smallest change in size allowable by the Resize method.
Describes the faces on which a part may be resized.
Determines the type of surface for the Right face of a part (+X direction).
The main rule in determining the root part of an assembly.
The rotation of the part in degrees for the three axes.
Determines the dimensions of a part (length, width, height).
Determines the type of surface for the Top face of a part (+Y direction).
Determines how much a part can be seen through (the inverse of part opacity).
Methods
Overwrites the MeshContent, TextureContent, and collision geometry properties of this MeshPart from the given source meshPart.
Apply an angular impulse to the assembly.
Apply an impulse to the assembly at the assembly's center of mass.
Apply an impulse to the assembly at specified position.
Returns whether the parts can collide with each other.
Checks whether you can set a part's network ownership.
Returns a table of parts connected to the object by any kind of rigid joint.
Return all Joints or Constraints that is connected to this Part.
Returns the value of the Mass property.
Returns the current player who is the network owner of this part, or nil in case of the server.
Returns true if the game engine automatically decides the network owner for this part.
Returns the base part of an assembly of parts.
Returns a table of all BasePart.CanCollide true parts that intersect with this part.
Returns the linear velocity of the part's assembly at the given position relative to this part.
Returns true if the object is connected to a part that will hold it in place (eg an Anchored part), otherwise returns false.
Changes the size of an object just like using the Studio resize tool.
Sets the given player as network owner for this and all connected parts.
Lets the game engine dynamically decide who will handle the part's physics (one of the clients or the server).
- IntersectAsync(parts : Instances,collisionfidelity : Enum.CollisionFidelity,renderFidelity : Enum.RenderFidelity):Instance
Creates a new IntersectOperation from the overlapping geometry of the part and the other parts in the given array.
- SubtractAsync(parts : Instances,collisionfidelity : Enum.CollisionFidelity,renderFidelity : Enum.RenderFidelity):Instance
Creates a new UnionOperation from the part, minus the geometry occupied by the parts in the given array.
- UnionAsync(parts : Instances,collisionfidelity : Enum.CollisionFidelity,renderFidelity : Enum.RenderFidelity):Instance
Creates a new UnionOperation from the part, plus the geometry occupied by the parts in the given array.
Gets the pivot of a PVInstance.
Transforms the PVInstance along with all of its descendant PVInstances such that the pivot is now located at the specified CFrame.
Events
Events inherited from BasePartFires when a part stops touching another part as a result of physical movement.
Fires when a part touches another part as a result of physical movement.
Properties
DoubleSided
This property determines whether to render both faces of polygons in the mesh. It is only changeable in Studio. This is useful for meshes that are typically modeled as "cards" such as a leaf, hair, or cloth.
HasJointOffset
HasSkinnedMesh
JointOffset
MeshContent
The mesh that is displayed on the MeshPart. Supports asset URIs and EditableMesh objects.
Note that this property cannot be changed directly by scripts, as the collision geometry of the mesh cannot be recomputed in realtime. See AssetService:CreateMeshPartAsync() as a method to create a new MeshPart from a given Content with a specified CollisionFidelity. MeshPart:ApplyMesh() can be used to overwrite the MeshContent, TextureContent, and collision geometry of an existing MeshPart.
MeshId
The asset URIs of the mesh that is displayed on the MeshPart. Reads and writes to MeshContent.
Note that this property cannot be changed directly by scripts, as the collision geometry of the mesh cannot be recomputed in realtime. See AssetService:CreateMeshPartAsync() as a method to create a new MeshPart from a given Content with a specified CollisionFidelity. MeshPart:ApplyMesh() can be used to overwrite the MeshContent, TextureContent, and collision geometry of an existing MeshPart.
RenderFidelity
This property determines the level of detail that the MeshPart will be shown in. It can be set to the possible values of the Enum.RenderFidelity enum.
The default value is Automatic, meaning the mesh's detail is based on its distance from the camera as outlined in the following table.
Distance From Camera | Render Fidelity | Example |
---|---|---|
Less than 250 studs | Highest | |
250-500 studs | Medium | |
500 or more studs | Lowest |
TextureContent
The texture applied to the MeshPart. Supports asset URIs and EditableImage objects.
When this property is set to Content.none, no texture will be applied to the mesh.
local Workspace = game:GetService("Workspace")local meshPart = Workspace.MeshPartmeshPart.TextureContent = Content.none -- No texture
Note that the MeshContent property cannot be directly changed during runtime but the texture can.
Changing a Mesh Texture
Using the TextureContent property, the texture of a mesh can be changed without having to re-upload the mesh. To do this, a new image can be uploaded to Roblox with the desired texture. The original texture image file can be obtained by exporting the mesh using the Export Selection option in Studio. The image file will be saved alongside the exported .obj file.
The new texture can then be uploaded to Roblox as a decal and its asset URI can be applied to the mesh using the TextureContent or TextureID property.
TextureContent can also be set to reference an EditableImage that has not been published yet.
local AssetService = game:GetService("AssetService")local Workspace = game:GetService("Workspace")local meshPart = Workspace.MeshPartlocal editableImage = AssetService:CreateEditableImageAsync(meshPart.TextureContent)meshPart.TextureContent = Content.fromObject(editableImage) -- Live updates
When TextureContent references an EditableImage, the texture will live update with any edits to the EditableImage object.
Making a Textured Mesh
A mesh can only be textured if the mesh has been UV mapped, referring to the practice of projecting a texture map onto a mesh. This cannot be done using Roblox Studio and must be done using an external 3D modeling application such as Blender.
TextureID
The texture applied to the MeshPart. Reads and writes to TextureContent.
When this property is set to an empty string, no texture will be applied to the mesh.
local Workspace = game:GetService("Workspace")local meshPart = Workspace.MeshPartmeshPart.TextureID = "" -- No texture
Note that the MeshPart.MeshId property cannot be changed during runtime but the texture can. See TextureContent for details.
Methods
ApplyMesh
Overwrites the MeshContent, TextureContent, and collision geometry properties of this MeshPart from the given source meshPart.
Most of these properties are read-only and cannot be changed during runtime on their own directly. To keep MeshContent and physics data in sync, they must be updated together.
Copies the following properties:
- MeshPart.MeshContent (implicitly updates MeshId)
- MeshPart.TextureContent (implicitly updates TextureID)
- MeshPart.CollisionFidelity (with any internal collision geometry)
- MeshPart.FluidFidelity (with any internal aero geometry)