PVInstance

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

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

ไม่สามารถสร้าง
ไม่สามารถเรียกดู

A PVInstance ("Position Velocity Instance") เป็นคลาสที่มีอยู่แล้ว มันเป็นพื้นฐานสำหรับวัตถุทั้งหมดที่มีสถานที่จริงในโลก โดยเฉพาะ BaseParts และ Models

สรุป

คุณสมบัติ

  • ไม่ซ้ำ
    ไม่สามารถเขียนสคริปต์
    อ่านพร้อมๆ กัน
  • ไม่ซ้ำ
    ไม่สามารถเขียนสคริปต์
    อ่านพร้อมๆ กัน

วิธีการ

  • เขียนพร้อมๆ กัน

    รับ pivot ของ Class.PVInstance

  • PivotTo(targetCFrame : CFrame):()

    แปลง PVInstance พร้อมกับบรรพบุรุษทั้งหมดของมัน PVInstances เพื่อให้ pivot ตอนนี้อยู่ที่ CFrame ที่กำหนด

คุณสมบัติ

Origin

ไม่ซ้ำ
ไม่สามารถเขียนสคริปต์
อ่านพร้อมๆ กัน

Pivot Offset

ไม่ซ้ำ
ไม่สามารถเขียนสคริปต์
อ่านพร้อมๆ กัน

วิธีการ

GetPivot

เขียนพร้อมๆ กัน

ฟังก์ชันนี้ได้รับการหมุนของ PVInstance นี้ ฟังก์ชันนี้มักใช้กับ PVInstance:PivotTo() เพื่อย้ายรุ่น

Models และ BaseParts ทั้งสองเป็น PVInstances ("ตําแหน่งความเร็วสถานะ") และดังนั้นทั้งสองจึงมีคุณสมบัตินี้


ส่งค่ากลับ

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

This code sample is a simple teleport script that moves your character 10 studs forwards in the direction you're currently facing when you press the F key. It does so by getting the current pivot with PVInstance:GetPivot() and calling PVInstance|PivotTo to move the character forwards.

Simple Character Teleportation

-- This code should be placed in a LocalScript under StarterPlayerScripts
local Players = game:GetService("Players")
local ContextActionService = game:GetService("ContextActionService")
local player = Players.LocalPlayer
local function doTeleport(_actionName, inputState, _inputObject)
local character = player.Character
if character and character.Parent and inputState == Enum.UserInputState.Begin then
-- Move the character 10 studs forwards in the direction they're facing
local currentPivot = character:GetPivot()
character:PivotTo(currentPivot * CFrame.new(0, 0, -10))
end
end
ContextActionService:BindAction("Teleport", doTeleport, true, Enum.KeyCode.F)

PivotTo

()

แปลง PVInstance พร้อมกับทั้งหมดของลูกหลานของมัน PVInstances เพื่อให้ pivot ตอนนี้ตั้งอยู่ที่ CFrame scriptingนี่คือการใ

BaseParts ย้ายในวิธีนี้โดยมี CFrame ของพวกเขาถูกแปลงโดยออเฟ็ตที่จำเป็น Models ย้ายในวิธีนี้โดยมี 0> Class.Model.WorldPivot0> ถู

หมุดหมายเหตุว่าสำหรับวัตถุประสงค์ในการประหยัดความเป็น เหตุการณ์ Object.Changed จะไม่ได้ถูกเรียกใช้สำหรับ Position และ <

เมื่อเรียก PivotTo บน Models จะมีการเรียกลัพธ์ของส่วนลูกสุดท้ายและโมเดลที่คงค้างไว้ เช่นเดียวกับการเรียกลัพธ

Models และ BaseParts ทั้งสองเป็น PVInstances ("ตําแหน่งความเร็วสถานะ") และดังนั้นทั้งสองจึงมีคุณสมบัตินี้

พารามิเตอร์

targetCFrame: CFrame

Datatype.CFrame ที่ Class.PVInstance หมุนจะต้องเท่ากันหลังจากย้ายมัน


ส่งค่ากลับ

()

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

This code sample is a simple teleport script that moves your character 10 studs forwards in the direction you're currently facing when you press the F key. It does so by getting the current pivot with PVInstance:GetPivot() and calling PVInstance|PivotTo to move the character forwards.

Simple Character Teleportation

-- This code should be placed in a LocalScript under StarterPlayerScripts
local Players = game:GetService("Players")
local ContextActionService = game:GetService("ContextActionService")
local player = Players.LocalPlayer
local function doTeleport(_actionName, inputState, _inputObject)
local character = player.Character
if character and character.Parent and inputState == Enum.UserInputState.Begin then
-- Move the character 10 studs forwards in the direction they're facing
local currentPivot = character:GetPivot()
character:PivotTo(currentPivot * CFrame.new(0, 0, -10))
end
end
ContextActionService:BindAction("Teleport", doTeleport, true, Enum.KeyCode.F)

อีเวนต์