Vector3Value

사용되지 않는 항목 표시

*이 콘텐츠는 AI(베타)를 사용해 번역되었으며, 오류가 있을 수 있습니다. 이 페이지를 영어로 보려면 여기를 클릭하세요.

Vector3Value는 벡터3을 값으로 단순히 저장합니다. 이 값은 스크립트 통신, 개체 이동 등에 사용될 수 있습니다.

코드 샘플

This code sample causes a Part to teleport any players that touch it to a specific position defined by a "TeleportPosition" Vector3Value.

Teleporter Part

-- Paste me in a Script inside a Part
local part = script.Parent
local teleportPosition = part.TeleportPosition
local function onTouch(otherPart)
-- First, find the HumanoidRootPart. If we can't find it, exit.
local hrp = otherPart.Parent:FindFirstChild("HumanoidRootPart")
if not hrp then
return
end
-- Now teleport by setting the CFrame to one created from
-- the stored TeleportPosition
hrp.CFrame = CFrame.new(teleportPosition.Value)
end
part.Touched:Connect(onTouch)

This code sample demonstrates how it is possible to store a Vector2 within a Vector3Value by converting a Vector2 into a Vector3 with a dummy Z value. Similarly, you can load it by reconstructing the Vector2 from the X and Y axes.

Storing Vector2 inside Vector3Value

local vector3Value = Instance.new("Vector3Value")
-- Store a Vector2 in a Vector3
local vector2 = Vector2.new(42, 70)
vector3Value.Value = Vector3.new(vector2.X, vector2.Y, 0) -- The Z value is ignored
-- Load a Vector2 from a Vector3
vector2 = Vector2.new(vector3Value.Value.X, vector3Value.Value.Y)
print(vector2)

속성

Value

병렬 읽기

저장된 Vector3 .

메서드

이벤트

Changed

Class.Vector3Value.Value 의 Class.Vector3Value 가 변경될 때마다 발생합니다. 새 값이 인수 개체에 저장되므로 속성이 변경되는 문자열이 아닙니다.

이 이벤트는 다른 변경된 이벤트와 마찬가지로 벡터3값이 변경될 때 추적하고 변경될 수 있는 다른 값을 추적하는 데 사용할 수 있습니다.

예를 인스턴스, 이 기능은 게임 세계에서 위치를 추적하는 벡터3값을 사용하는 게임에 유용할 수 있습니다.

변경된 이벤트는 대상, 예를 들어 NumberValueStringValue와 같은 유사한 개체에 대해 변경된 이벤트가 있습니다. 필요에 가장 적합한 개체 유형에 따라 Class.StringValue 및 2>Class.NumberValue2>가 있습니다.

매개 변수

value: Vector3

변경 후의 새 값.


코드 샘플

The below example, assuming all referenced objects existed, would print the Vector3Value's new value each time it changed. In the example below it would print "10,10,10".

How to Use Vector3Value.Changed

local value = Instance.new("Vector3Value")
value.Parent = workspace
value.Changed:Connect(function(NewValue)
print(NewValue)
end)
value.Value = Vector3.new(10, 10, 10)