SpecialMesh

แสดงที่เลิกใช้งานแล้ว

*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่

วัตถุ SpecialMesh ใช้เมชให้กับ BasePart ขึ้นอยู่กับคุณสมบัติ MeshType มีตัวเลือกจํานวนมาก

  • อิฐ - รูปแบบบล็อกที่เทียบเท่ากับ BlockMesh
  • ทรงกระบอก - ทรงกระบอกที่เหมือนกับ Part ด้วย Part.Shape ของ 'ทรงกระบอก'
  • FileMesh - ผู้ใช้อัปโหลด Mesh ที่เทียบเท่ากับ FileMesh ที่เทกเจอร์สามารถใช้ได้โดยใช้คุณสมบัติ FileMesh.TextureId
  • หัว - รูปร่างหัวตัวละคร
  • ทรงกลม - ทรงกลมรูปร่างคล้ายกับ Part ที่มี Part.Shape ของ "ลูกบอล" แต่สามารถปรับขนาดได้อย่างอิสระในทุกแกน
  • บล็อกลิ่น - รูปทรงบล็อกลิ่นที่เหมือนกับ WedgePart
  • ลําตัว - บล็อกที่มีด้านลาดเอียงเนื่องจากจะถูกลบออก

โปรดทราบว่าแต่ละ SpecialMesh.MeshType จะมีขนาดแตกต่างกันเมื่อใช้ DataModelMesh.Scale สำหรับข้อมูลเพิ่มเติมเกี่ยวกับเรื่องนี้โปรดดูที่หน้า DataModelMesh.Scaleวัตถุ SpecialMesh ยังเปิดเผยคุณสมบัติ DataModelMesh.Offset

เป็นสิ่งสำคัญที่ต้องจำไว้ว่าเมื่อใช้ SpecialMesh เพียงรูปลักษณ์ของส่วนเปลี่ยนแปลงเท่านั้นโมเดลการชนของชิ้นส่วนยังคงเหมือนเดิมตัวอย่างเช่น บัญชี

SpecialMesh กับ MeshPart

ขณะนี้มีสองวิธีในการใช้เมชที่สร้างขึ้นโดยนักพัฒนาอยู่พวกเขากำลังใช้ SpecialMesh ด้วยการตั้งค่า SpecialMesh.FileType เป็น 'FileMesh' หรือโดยใช้ MeshPartแม้ว่าโดยรวมแล้ววัตถุ MeshPart จะได้แทนที่เนื้อหาพิเศษของเมชที่มีอยู่แล้ว แต่มีบางส่วนที่นักพัฒนาควรรู้

  • BasePart.Material แสดงอย่างถูกต้องบนเมชเมื่อใช้ MeshPart และไม่ใช่เมื่อใช้เมชพิเศษ
  • MeshParts รวมคุณสมบัติ MeshPart.CollisionFidelity ซึ่งหมายความว่าโมเดลการชนกันของ MeshPart สามารถตั้งค่าให้คล้ายกับรูปทรงของเมชวัตถุ SpecialMesh โดยการเปรียบเทียบใช้โมเดลการชนกันของพ่อ BaseParts
  • เมชของ MeshPart เครือข่ายบนแกนทั้งหมดขึ้นอยู่กับคุณสมบัติ Size ของ MeshPart เมชพิเศษไม่ได้
  • วัตถุ SpecialMesh รวมถึงคุณสมบัติ Offset และ Scale ในขณะที่ MeshParts ไม่
  • คุณสมบัติ MeshId ของ SpecialMesh สามารถเปลี่ยนแปลงได้โดย Script หรือ LocalScript ในระหว่างการทำงานคุณสมบัติ MeshId ของ a MeshPart ไม่สามารถ

ตัวอย่างโค้ด

In this code sample a BasePart is instanced with a SpecialMesh. The DataModelMesh.Scale and DataModelMesh.Offset properties of the SpecialMesh are then animated using TweenService.

Mesh Offset and Scale

local TweenService = game:GetService("TweenService")
-- instance a part and a mesh
local part = Instance.new("Part")
part.Size = Vector3.new(4, 8, 4)
part.Position = Vector3.new(0, 4, 0)
part.Anchored = true
part.CanCollide = false
local mesh = Instance.new("SpecialMesh")
mesh.MeshType = Enum.MeshType.FileMesh
mesh.MeshId = "rbxassetid://1086413449"
mesh.TextureId = "rbxassetid://1461576423"
mesh.Offset = Vector3.new(0, 0, 0)
mesh.Scale = Vector3.new(4, 4, 4)
mesh.Parent = part
-- selection box to show part extents
local box = Instance.new("SelectionBox")
box.Adornee = part
box.Parent = part
-- parent part to workspace
part.Parent = workspace
-- animate offset and scale with a tween
local tween = TweenService:Create(
mesh,
TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, -1, true, 0),
{ Scale = Vector3.new(1, 1, 1), Offset = Vector3.new(0, 3, 0) }
)
tween:Play()

In this code sample a BasePart is instanced with a SpecialMesh. The DataModelMesh.VertexColor property of the SpecialMesh is then animated using TweenService.

Mesh VertexColor

local TweenService = game:GetService("TweenService")
-- instance a part and a mesh
local part = Instance.new("Part")
part.Size = Vector3.new(4, 8, 4)
part.Position = Vector3.new(0, 4, 0)
part.Anchored = true
part.CanCollide = false
local mesh = Instance.new("SpecialMesh")
mesh.MeshType = Enum.MeshType.FileMesh
mesh.MeshId = "rbxassetid://1086413449"
mesh.TextureId = "rbxassetid://1461576423"
mesh.Offset = Vector3.new(0, 0, 0)
mesh.Scale = Vector3.new(4, 4, 4)
mesh.VertexColor = Vector3.new(1, 1, 1)
mesh.Parent = part
-- parent part to workspace
part.Parent = workspace
-- create tweens
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
local blackTween = TweenService:Create(mesh, tweenInfo, { VertexColor = Vector3.new(0, 0, 0) })
local redTween = TweenService:Create(mesh, tweenInfo, { VertexColor = Vector3.new(1, 0, 0) })
local greenTween = TweenService:Create(mesh, tweenInfo, { VertexColor = Vector3.new(0, 1, 0) })
local blueTween = TweenService:Create(mesh, tweenInfo, { VertexColor = Vector3.new(0, 0, 1) })
local resetTween = TweenService:Create(mesh, tweenInfo, { VertexColor = Vector3.new(1, 1, 1) })
-- animate
while true do
blackTween:Play()
blackTween.Completed:Wait()
redTween:Play()
redTween.Completed:Wait()
greenTween:Play()
greenTween.Completed:Wait()
blueTween:Play()
blueTween.Completed:Wait()
resetTween:Play()
resetTween.Completed:Wait()
task.wait()
end

สรุป

คุณสมบัติ

  • อ่านพร้อมๆ กัน

    กำหนดประเภทของเมชที่จะถูกใช้กับ BasePart ที่ SpecialMesh ได้รับการสืบทอด

คุณสมบัติรับทอดมาจากFileMesh
  • MeshId:ContentId
    อ่านพร้อมๆ กัน

    MeshId เป็นรหัสเนื้อหาของเมชที่จะแสดง

  • TextureId:ContentId
    อ่านพร้อมๆ กัน

    TextureId เป็นรหัสเนื้อหาของเทกเจอร์ที่จะถูกใช้กับเมช

คุณสมบัติรับทอดมาจากDataModelMesh
  • อ่านพร้อมๆ กัน

    ค่าส่วนลบของเมชจะกำหนดตำแหน่งที่สัมพันธ์จาก BasePart.Position ของเมชที่จะแสดงที่ BasePart ซึ่งเมชจะแสดงที่

  • อ่านพร้อมๆ กัน

    ขนาดของเมชจะกำหนดขนาดของเมชเมื่อเทียบกับขนาดเดิมของมัน

  • อ่านพร้อมๆ กัน

    เปลี่ยนสีของเทกเจอร์ของเมชที่ใช้กับ FileMesh.TextureId

คุณสมบัติ

อ่านพร้อมๆ กัน

เมชที่วัตถุ SpecialMesh ใช้กับ BasePart ขึ้นอยู่กับคุณสมบัติ MeshType มีตัวเลือกหลายตัว

  • อิฐ - รูปแบบบล็อกที่เทียบเท่ากับ BlockMesh
  • ทรงกระบอก - ทรงกระบอกที่เหมือนกับ Part ด้วย Part.Shape ของ 'ทรงกระบอก'
  • FileMesh - ผู้ใช้อัปโหลด Mesh ที่เทียบเท่ากับ FileMesh ที่เทกเจอร์สามารถใช้ได้โดยใช้คุณสมบัติ FileMesh.TextureId
  • หัว - รูปร่างหัวตัวละคร
  • ทรงกลม - ทรงกลมรูปร่างคล้ายกับ Part ที่มี Part.Shape ของ "ลูกบอล" แต่สามารถปรับขนาดได้อย่างอิสระในทุกแกน
  • บล็อกลิ่น - รูปทรงบล็อกลิ่นที่เหมือนกับ WedgePart
  • ลําตัว - บล็อกที่มีด้านลาดเอียงเนื่องจากจะถูกลบออก

โปรดทราบว่าแต่ละประเภทเมชจะมีขนาดแตกต่างกันเมื่อใช้ DataModelMesh.Scale สำหรับข้อมูลเพิ่มเติมเกี่ยวกับเรื่องนี้โปรดดูที่หน้า DataModelMesh.Scale

ตัวอย่างโค้ด

In this code sample a BasePart is instanced with a SpecialMesh. The DataModelMesh.VertexColor property of the SpecialMesh is then animated using TweenService.

Mesh VertexColor

local TweenService = game:GetService("TweenService")
-- instance a part and a mesh
local part = Instance.new("Part")
part.Size = Vector3.new(4, 8, 4)
part.Position = Vector3.new(0, 4, 0)
part.Anchored = true
part.CanCollide = false
local mesh = Instance.new("SpecialMesh")
mesh.MeshType = Enum.MeshType.FileMesh
mesh.MeshId = "rbxassetid://1086413449"
mesh.TextureId = "rbxassetid://1461576423"
mesh.Offset = Vector3.new(0, 0, 0)
mesh.Scale = Vector3.new(4, 4, 4)
mesh.VertexColor = Vector3.new(1, 1, 1)
mesh.Parent = part
-- parent part to workspace
part.Parent = workspace
-- create tweens
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
local blackTween = TweenService:Create(mesh, tweenInfo, { VertexColor = Vector3.new(0, 0, 0) })
local redTween = TweenService:Create(mesh, tweenInfo, { VertexColor = Vector3.new(1, 0, 0) })
local greenTween = TweenService:Create(mesh, tweenInfo, { VertexColor = Vector3.new(0, 1, 0) })
local blueTween = TweenService:Create(mesh, tweenInfo, { VertexColor = Vector3.new(0, 0, 1) })
local resetTween = TweenService:Create(mesh, tweenInfo, { VertexColor = Vector3.new(1, 1, 1) })
-- animate
while true do
blackTween:Play()
blackTween.Completed:Wait()
redTween:Play()
redTween.Completed:Wait()
greenTween:Play()
greenTween.Completed:Wait()
blueTween:Play()
blueTween.Completed:Wait()
resetTween:Play()
resetTween.Completed:Wait()
task.wait()
end

วิธีการ

อีเวนต์