Vector3Value
*Bu içerik, yapay zekâ (beta) kullanılarak çevrildi ve hatalar içerebilir. Sayfayı İngilizce görüntülemek için buraya tıkla.
Bir Vector3Value basitçe bir Vector3'ü bir değer olarak tutar. Bu değer, senaryolar iletişim kurmak, nesneler bir ön ayara taşınmak vb. için kullanılabilir.
Kod Örnekleri
This code sample causes a Part to teleport any players that touch it to a specific position defined by a "TeleportPosition" Vector3Value.
-- 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.
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)
Özet
Özellikler
Depolandı Vector3 .
Etkinlikler
Herhangi bir değişiklik yapıldığında Vector3Value.Value ateşlenir.
Özellikler
Yöntemler
Etkinlikler
Changed
Ateş edildiğinde, Vector3Value.Value ın Vector3Value değiştirildiği her an.Değiştirilen özellikleri temsil eden bir dize yerine yeni değer depolanarak argüman nesnesinde çalışacaktır. It will run with the new value being stored in the argument object, instead of a string representing the property being changed.
Bu olay, diğer değiştirilen olaylar gibi, bir Vector3Value değiştiğinde izlenebilir ve değişebileceği farklı değerleri izleyebilir.
durum, bu, oyun dünyasındaki konumları izlemek için Vector3Values'a güvenen oyunlarda yararlı olabilir.
Eşdeğer değiştirilen olaylar, ihtiyaca en iyi uyan nesne türüne bağlı olarak, örneğin NumberValue ve StringValue gibi benzer nesneler için mevcuttur.
Parametreler
Değişiklikten sonra yeni değer.
Kod Örnekleri
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".
local value = Instance.new("Vector3Value")
value.Parent = workspace
value.Changed:Connect(function(NewValue)
print(NewValue)
end)
value.Value = Vector3.new(10, 10, 10)